Skip to content

Commit

Permalink
Fix issue with nextTick running before the refresh is complete when u…
Browse files Browse the repository at this point in the history
…sing transitions or x-for directives
  • Loading branch information
SimoTod committed Apr 3, 2020
1 parent 85bb4a2 commit 8fe6c8d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 38 deletions.
51 changes: 28 additions & 23 deletions dist/alpine-ie11.js
Expand Up @@ -23,10 +23,10 @@
return module = { exports: {} }, fn(module, module.exports), module.exports;
}

(function(){function k(){function p(a){return a?"object"===typeof a||"function"===typeof a:!1}var l=null;var n=function(a,c){function g(){}if(!p(a)||!p(c))throw new TypeError("Cannot create proxy with a non-object as target or handler");l=function(){a=null;g=function(b){throw new TypeError("Cannot perform '"+b+"' on a proxy that has been revoked");};};setTimeout(function(){l=null;},0);var f=c;c={get:null,set:null,apply:null,construct:null};for(var h in f){if(!(h in c))throw new TypeError("Proxy polyfill does not support trap '"+
h+"'");c[h]=f[h];}"function"===typeof f&&(c.apply=f.apply.bind(f));var d=this,q=!1,r=!1;"function"===typeof a?(d=function(){var b=this&&this.constructor===d,e=Array.prototype.slice.call(arguments);g(b?"construct":"apply");return b&&c.construct?c.construct.call(this,a,e):!b&&c.apply?c.apply(a,this,e):b?(e.unshift(a),new (a.bind.apply(a,e))):a.apply(this,e)},q=!0):a instanceof Array&&(d=[],r=!0);var t=c.get?function(b){g("get");return c.get(this,b,d)}:function(b){g("get");return this[b]},w=c.set?function(b,
e){g("set");c.set(this,b,e,d);}:function(b,e){g("set");this[b]=e;},u={};Object.getOwnPropertyNames(a).forEach(function(b){if(!((q||r)&&b in d)){var e={enumerable:!!Object.getOwnPropertyDescriptor(a,b).enumerable,get:t.bind(a,b),set:w.bind(a,b)};Object.defineProperty(d,b,e);u[b]=!0;}});f=!0;Object.setPrototypeOf?Object.setPrototypeOf(d,Object.getPrototypeOf(a)):d.__proto__?d.__proto__=a.__proto__:f=!1;if(c.get||!f)for(var m in a)u[m]||Object.defineProperty(d,m,{get:t.bind(a,m)});Object.seal(a);Object.seal(d);
return d};n.revocable=function(a,c){return {proxy:new n(a,c),revoke:l}};return n}var v="undefined"!==typeof process&&"[object process]"==={}.toString.call(process)||"undefined"!==typeof navigator&&"ReactNative"===navigator.product?commonjsGlobal:self;v.Proxy||(v.Proxy=k(),v.Proxy.revocable=v.Proxy.revocable);})();
(function(){function l(){function n(a){return a?"object"===typeof a||"function"===typeof a:!1}var p=null;var g=function(a,b){function f(){}if(!n(a)||!n(b))throw new TypeError("Cannot create proxy with a non-object as target or handler");p=function(){f=function(a){throw new TypeError("Cannot perform '"+a+"' on a proxy that has been revoked");};};var e=b;b={get:null,set:null,apply:null,construct:null};for(var k in e){if(!(k in b))throw new TypeError("Proxy polyfill does not support trap '"+k+"'");b[k]=e[k];}"function"===
typeof e&&(b.apply=e.apply.bind(e));var c=this,g=!1,q=!1;"function"===typeof a?(c=function(){var h=this&&this.constructor===c,d=Array.prototype.slice.call(arguments);f(h?"construct":"apply");return h&&b.construct?b.construct.call(this,a,d):!h&&b.apply?b.apply(a,this,d):h?(d.unshift(a),new (a.bind.apply(a,d))):a.apply(this,d)},g=!0):a instanceof Array&&(c=[],q=!0);var r=b.get?function(a){f("get");return b.get(this,a,c)}:function(a){f("get");return this[a]},v=b.set?function(a,d){f("set");b.set(this,
a,d,c);}:function(a,b){f("set");this[a]=b;},t={};Object.getOwnPropertyNames(a).forEach(function(b){if(!((g||q)&&b in c)){var d={enumerable:!!Object.getOwnPropertyDescriptor(a,b).enumerable,get:r.bind(a,b),set:v.bind(a,b)};Object.defineProperty(c,b,d);t[b]=!0;}});e=!0;Object.setPrototypeOf?Object.setPrototypeOf(c,Object.getPrototypeOf(a)):c.__proto__?c.__proto__=a.__proto__:e=!1;if(b.get||!e)for(var m in a)t[m]||Object.defineProperty(c,m,{get:r.bind(a,m)});Object.seal(a);Object.seal(c);return c};g.revocable=
function(a,b){return {proxy:new g(a,b),revoke:p}};return g}var u="undefined"!==typeof process&&"[object process]"==={}.toString.call(process)||"undefined"!==typeof navigator&&"ReactNative"===navigator.product?commonjsGlobal:self;u.Proxy||(u.Proxy=l(),u.Proxy.revocable=u.Proxy.revocable);})();

!function(e){var t=e.Element.prototype;"function"!=typeof t.matches&&(t.matches=t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),o=0;t[o]&&t[o]!==this;)++o;return Boolean(t[o])}),"function"!=typeof t.closest&&(t.closest=function(e){for(var t=this;t&&1===t.nodeType;){if(t.matches(e))return t;t=t.parentNode;}return null});}(window);

Expand Down Expand Up @@ -2499,7 +2499,7 @@
return { __await: arg };
};

function AsyncIterator(generator, PromiseImpl) {
function AsyncIterator(generator) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
Expand All @@ -2510,14 +2510,14 @@
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return PromiseImpl.resolve(value.__await).then(function(value) {
return Promise.resolve(value.__await).then(function(value) {
invoke("next", value, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
});
}

return PromiseImpl.resolve(value).then(function(unwrapped) {
return Promise.resolve(value).then(function(unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration.
Expand All @@ -2535,7 +2535,7 @@

function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function(resolve, reject) {
return new Promise(function(resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
Expand Down Expand Up @@ -2575,12 +2575,9 @@
// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
if (PromiseImpl === void 0) PromiseImpl = Promise;

exports.async = function(innerFn, outerFn, self, tryLocsList) {
var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList),
PromiseImpl
wrap(innerFn, outerFn, self, tryLocsList)
);

return exports.isGeneratorFunction(outerFn)
Expand Down Expand Up @@ -6043,7 +6040,9 @@
return new Proxy(target, proxyHandler);
}

var Component = /*#__PURE__*/function () {
var Component =
/*#__PURE__*/
function () {
function Component(el) {
var _this = this;

Expand Down Expand Up @@ -6233,9 +6232,11 @@
}.bind(this));
this.executeAndClearRemainingShowDirectiveStack(); // Walk through the $nextTick stack and clear it as we go.

while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
debounce(function () {
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
}, 0).bind(this)();
}
}, {
key: "initializeElement",
Expand Down Expand Up @@ -6268,11 +6269,13 @@

el.__x = new Component(el);
}.bind(this));
this.executeAndClearRemainingShowDirectiveStack(); // Walk through the $nextTick stack and clear it as we go.

while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
this.executeAndClearRemainingShowDirectiveStack();
debounce(function () {
// Walk through the $nextTick stack and clear it as we go.
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
}, 0).bind(this)();
}
}, {
key: "executeAndClearRemainingShowDirectiveStack",
Expand Down Expand Up @@ -6567,7 +6570,9 @@

var Alpine = {
start: function () {
var _start = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var _start = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var _this = this;

return regeneratorRuntime.wrap(function _callee$(_context) {
Expand Down
20 changes: 12 additions & 8 deletions dist/alpine.js
Expand Up @@ -1381,9 +1381,11 @@
});
this.executeAndClearRemainingShowDirectiveStack(); // Walk through the $nextTick stack and clear it as we go.

while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
debounce(function () {
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
}, 0).bind(this)();
}

initializeElement(el, extraVars) {
Expand All @@ -1405,11 +1407,13 @@
}, el => {
el.__x = new Component(el);
});
this.executeAndClearRemainingShowDirectiveStack(); // Walk through the $nextTick stack and clear it as we go.

while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
this.executeAndClearRemainingShowDirectiveStack();
debounce(function () {
// Walk through the $nextTick stack and clear it as we go.
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()();
}
}, 0).bind(this)();
}

executeAndClearRemainingShowDirectiveStack() {
Expand Down
18 changes: 11 additions & 7 deletions src/component.js
Expand Up @@ -152,9 +152,11 @@ export default class Component {
this.executeAndClearRemainingShowDirectiveStack()

// Walk through the $nextTick stack and clear it as we go.
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()()
}
debounce(function() {
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()()
}
}, 0).bind(this)()
}

initializeElement(el, extraVars) {
Expand All @@ -180,10 +182,12 @@ export default class Component {

this.executeAndClearRemainingShowDirectiveStack()

// Walk through the $nextTick stack and clear it as we go.
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()()
}
debounce(function() {
// Walk through the $nextTick stack and clear it as we go.
while (this.nextTickStack.length > 0) {
this.nextTickStack.shift()()
}
}, 0).bind(this)()
}

executeAndClearRemainingShowDirectiveStack() {
Expand Down

0 comments on commit 8fe6c8d

Please sign in to comment.