Skip to content

Commit 99907d1

Browse files
committed
Release 2.1.0
1 parent 86dbc36 commit 99907d1

7 files changed

+39
-9
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [2.1.0] - 2016-11-24
2+
3+
### Changed
4+
- Away callback may not be triggered until the end of the initial macrotask (fixes #8)
5+
16
## [2.0.0] - 2016-10-20
27

38
### Breaking changes
@@ -79,3 +84,4 @@ Initial release
7984

8085
[2.0.0-rc.1]: https://github.com/simplesmiler/vue-clickaway/compare/1.1.5...2.0.0-rc.1
8186
[2.0.0]: https://github.com/simplesmiler/vue-clickaway/compare/2.0.0-rc.1...2.0.0
87+
[2.1.0]: https://github.com/simplesmiler/vue-clickaway/compare/2.0.0...2.1.0

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ $ npm install vue-clickaway --save
2828
From CDN:
2929

3030
``` html
31-
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/2.0.0/dist/vue-clickaway.js"></script>
31+
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/2.1.0/dist/vue-clickaway.js"></script>
3232
<!-- OR -->
33-
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/2.0.0/dist/vue-clickaway.min.js"></script>
33+
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/2.1.0/dist/vue-clickaway.min.js"></script>
3434
```
3535

3636
## Usage

dist/vue-clickaway.common.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Vue = require('vue');
44
Vue = 'default' in Vue ? Vue['default'] : Vue;
55

6-
var version = '2.0.0';
6+
var version = '2.1.0';
77

88
var compatible = (/^2\./).test(Vue.version);
99
if (!compatible) {
@@ -31,10 +31,22 @@ function bind(el, binding) {
3131
return;
3232
}
3333

34+
// @NOTE: Vue binds directives in microtasks, while UI events are dispatched
35+
// in macrotasks. This causes the listener to be set up before
36+
// the "origin" click event (the event that lead to the binding of
37+
// the directive) arrives at the document root. To work around that,
38+
// we ignore events until the end of the "initial" macrotask.
39+
// @REFERENCE: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
40+
// @REFERENCE: https://github.com/simplesmiler/vue-clickaway/issues/8
41+
var initialMacrotaskEnded = false;
42+
setTimeout(function() {
43+
initialMacrotaskEnded = true;
44+
}, 0);
45+
3446
el[HANDLER] = function(ev) {
3547
// @NOTE: IE 5.0+
3648
// @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
37-
if (!el.contains(ev.target)) {
49+
if (initialMacrotaskEnded && !el.contains(ev.target)) {
3850
return callback(ev);
3951
}
4052
};

dist/vue-clickaway.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Vue = 'default' in Vue ? Vue['default'] : Vue;
44

5-
var version = '2.0.0';
5+
var version = '2.1.0';
66

77
var compatible = (/^2\./).test(Vue.version);
88
if (!compatible) {
@@ -30,10 +30,22 @@
3030
return;
3131
}
3232

33+
// @NOTE: Vue binds directives in microtasks, while UI events are dispatched
34+
// in macrotasks. This causes the listener to be set up before
35+
// the "origin" click event (the event that lead to the binding of
36+
// the directive) arrives at the document root. To work around that,
37+
// we ignore events until the end of the "initial" macrotask.
38+
// @REFERENCE: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
39+
// @REFERENCE: https://github.com/simplesmiler/vue-clickaway/issues/8
40+
var initialMacrotaskEnded = false;
41+
setTimeout(function() {
42+
initialMacrotaskEnded = true;
43+
}, 0);
44+
3345
el[HANDLER] = function(ev) {
3446
// @NOTE: IE 5.0+
3547
// @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
36-
if (!el.contains(ev.target)) {
48+
if (initialMacrotaskEnded && !el.contains(ev.target)) {
3749
return callback(ev);
3850
}
3951
};

dist/vue-clickaway.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue';
22

3-
export var version = '2.0.0';
3+
export var version = '2.1.0';
44

55
var compatible = (/^2\./).test(Vue.version);
66
if (!compatible) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-clickaway",
33
"description": "Reusable clickaway directive for reusable Vue.js components",
4-
"version": "2.0.0",
4+
"version": "2.1.0",
55
"author": "Denis Karabaza <[email protected]>",
66
"browserify": {
77
"transform": [

0 commit comments

Comments
 (0)