Skip to content

Commit 80a023a

Browse files
committed
Release 1.2.0
1 parent d581085 commit 80a023a

7 files changed

+49
-9
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [1.2.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
## [1.1.5] - 2016-09-30
27

38
Skipped 1.1.4 due to publising mistake
@@ -64,3 +69,4 @@ Initial release
6469
[1.1.2]: https://github.com/simplesmiler/vue-clickaway/compare/1.1.1...1.1.2
6570
[1.1.3]: https://github.com/simplesmiler/vue-clickaway/compare/1.1.2...1.1.3
6671
[1.1.5]: https://github.com/simplesmiler/vue-clickaway/compare/1.1.3...1.1.5
72+
[1.2.0]: https://github.com/simplesmiler/vue-clickaway/compare/1.1.5...1.2.0

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ $ npm install vue-clickaway --save
2626
From CDN:
2727

2828
``` html
29-
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/1.1.5/dist/vue-clickaway.js"></script>
29+
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/1.2.0/dist/vue-clickaway.js"></script>
3030
<!-- OR -->
31-
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/1.1.5/dist/vue-clickaway.min.js"></script>
31+
<script src="https://cdn.rawgit.com/simplesmiler/vue-clickaway/1.2.0/dist/vue-clickaway.min.js"></script>
3232
```
3333

3434
## Usage

dist/vue-clickaway.common.js

+19-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 = '1.1.5';
6+
var version = '1.2.0';
77

88
var compatible = (/^1\./).test(Vue.version);
99
if (!compatible) {
@@ -15,6 +15,22 @@ var directive = {
1515
acceptStatement: true,
1616
priority: 700,
1717

18+
bind: function() {
19+
var self = this;
20+
21+
// @NOTE: Vue binds directives in microtasks, while UI events are dispatched
22+
// in macrotasks. This causes the listener to be set up before
23+
// the "origin" click event (the event that lead to the binding of
24+
// the directive) arrives at the document root. To work around that,
25+
// we ignore events until the end of the "initial" macrotask.
26+
// @REFERENCE: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
27+
// @REFERENCE: https://github.com/simplesmiler/vue-clickaway/issues/8
28+
self.initialMacrotaskEnded = false;
29+
setTimeout(function() {
30+
self.initialMacrotaskEnded = true;
31+
});
32+
},
33+
1834
update: function(handler) {
1935
if (typeof handler !== 'function') {
2036
if (process.env.NODE_ENV !== 'production') {
@@ -29,13 +45,14 @@ var directive = {
2945

3046
this.reset();
3147

48+
var self = this;
3249
var el = this.el;
3350
var scope = this._scope || this.vm;
3451

3552
this.handler = function(ev) {
3653
// @NOTE: IE 5.0+
3754
// @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
38-
if (!el.contains(ev.target)) {
55+
if (self.initialMacrotaskEnded && !el.contains(ev.target)) {
3956
scope.$event = ev;
4057
var res = handler(ev);
4158
scope.$event = null;

dist/vue-clickaway.js

+19-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 = '1.1.5';
5+
var version = '1.2.0';
66

77
var compatible = (/^1\./).test(Vue.version);
88
if (!compatible) {
@@ -14,6 +14,22 @@
1414
acceptStatement: true,
1515
priority: 700,
1616

17+
bind: function() {
18+
var self = this;
19+
20+
// @NOTE: Vue binds directives in microtasks, while UI events are dispatched
21+
// in macrotasks. This causes the listener to be set up before
22+
// the "origin" click event (the event that lead to the binding of
23+
// the directive) arrives at the document root. To work around that,
24+
// we ignore events until the end of the "initial" macrotask.
25+
// @REFERENCE: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
26+
// @REFERENCE: https://github.com/simplesmiler/vue-clickaway/issues/8
27+
self.initialMacrotaskEnded = false;
28+
setTimeout(function() {
29+
self.initialMacrotaskEnded = true;
30+
});
31+
},
32+
1733
update: function(handler) {
1834
if (typeof handler !== 'function') {
1935
if ('development' !== 'production') {
@@ -28,13 +44,14 @@
2844

2945
this.reset();
3046

47+
var self = this;
3148
var el = this.el;
3249
var scope = this._scope || this.vm;
3350

3451
this.handler = function(ev) {
3552
// @NOTE: IE 5.0+
3653
// @REFERENCE: https://developer.mozilla.org/en/docs/Web/API/Node/contains
37-
if (!el.contains(ev.target)) {
54+
if (self.initialMacrotaskEnded && !el.contains(ev.target)) {
3855
scope.$event = ev;
3956
var res = handler(ev);
4057
scope.$event = null;

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 = '1.1.5';
3+
export var version = '1.2.0';
44

55
var compatible = (/^1\./).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": "1.1.5",
4+
"version": "1.2.0",
55
"author": "Denis Karabaza <[email protected]>",
66
"browserify": {
77
"transform": [

0 commit comments

Comments
 (0)