Skip to content

Commit 9cb3a47

Browse files
committed
chore: publish [email protected]
1 parent 4f47f41 commit 9cb3a47

File tree

2 files changed

+120
-47
lines changed

2 files changed

+120
-47
lines changed

packages/weex-vue-framework/factory.js

Lines changed: 119 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,49 +1766,60 @@ var microTimerFunc;
17661766
var macroTimerFunc;
17671767
var useMacroTask = false;
17681768

1769-
// Determine (macro) task defer implementation.
1770-
// Technically setImmediate should be the ideal choice, but it's only available
1771-
// in IE. The only polyfill that consistently queues the callback after all DOM
1772-
// events triggered in the same loop is by using MessageChannel.
1773-
/* istanbul ignore if */
1774-
if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
1775-
macroTimerFunc = function () {
1776-
setImmediate(flushCallbacks);
1777-
};
1778-
} else if (typeof MessageChannel !== 'undefined' && (
1779-
isNative(MessageChannel) ||
1780-
// PhantomJS
1781-
MessageChannel.toString() === '[object MessageChannelConstructor]'
1782-
)) {
1783-
var channel = new MessageChannel();
1784-
var port = channel.port2;
1785-
channel.port1.onmessage = flushCallbacks;
1786-
macroTimerFunc = function () {
1787-
port.postMessage(1);
1788-
};
1789-
} else {
1790-
/* istanbul ignore next */
1791-
macroTimerFunc = function () {
1792-
setTimeout(flushCallbacks, 0);
1793-
};
1769+
function initTimerFunc () {
1770+
// Determine (macro) task defer implementation.
1771+
// Technically setImmediate should be the ideal choice, but it's only available
1772+
// in IE. The only polyfill that consistently queues the callback after all DOM
1773+
// events triggered in the same loop is by using MessageChannel.
1774+
/* istanbul ignore if */
1775+
if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
1776+
macroTimerFunc = function () {
1777+
setImmediate(flushCallbacks);
1778+
};
1779+
} else if (typeof MessageChannel !== 'undefined' && (
1780+
isNative(MessageChannel) ||
1781+
// PhantomJS
1782+
MessageChannel.toString() === '[object MessageChannelConstructor]'
1783+
)) {
1784+
var channel = new MessageChannel();
1785+
var port = channel.port2;
1786+
channel.port1.onmessage = flushCallbacks;
1787+
macroTimerFunc = function () {
1788+
port.postMessage(1);
1789+
};
1790+
} else {
1791+
/* istanbul ignore next */
1792+
macroTimerFunc = function () {
1793+
setTimeout(flushCallbacks, 0);
1794+
};
1795+
}
1796+
1797+
// Determine microtask defer implementation.
1798+
/* istanbul ignore next, $flow-disable-line */
1799+
if (typeof Promise !== 'undefined' && isNative(Promise)) {
1800+
var p = Promise.resolve();
1801+
microTimerFunc = function () {
1802+
p.then(flushCallbacks);
1803+
// in problematic UIWebViews, Promise.then doesn't completely break, but
1804+
// it can get stuck in a weird state where callbacks are pushed into the
1805+
// microtask queue but the queue isn't being flushed, until the browser
1806+
// needs to do some other work, e.g. handle a timer. Therefore we can
1807+
// "force" the microtask queue to be flushed by adding an empty timer.
1808+
if (!inWeex && isIOS) { setTimeout(noop); }
1809+
};
1810+
} else {
1811+
// fallback to macro
1812+
microTimerFunc = macroTimerFunc;
1813+
}
17941814
}
1815+
initTimerFunc();
17951816

1796-
// Determine microtask defer implementation.
1797-
/* istanbul ignore next, $flow-disable-line */
1798-
if (typeof Promise !== 'undefined' && isNative(Promise)) {
1799-
var p = Promise.resolve();
1800-
microTimerFunc = function () {
1801-
p.then(flushCallbacks);
1802-
// in problematic UIWebViews, Promise.then doesn't completely break, but
1803-
// it can get stuck in a weird state where callbacks are pushed into the
1804-
// microtask queue but the queue isn't being flushed, until the browser
1805-
// needs to do some other work, e.g. handle a timer. Therefore we can
1806-
// "force" the microtask queue to be flushed by adding an empty timer.
1807-
if (isIOS) { setTimeout(noop); }
1808-
};
1809-
} else {
1810-
// fallback to macro
1811-
microTimerFunc = macroTimerFunc;
1817+
function resetTimerFunc () {
1818+
callbacks.length = 0;
1819+
pending = false;
1820+
microTimerFunc = null;
1821+
macroTimerFunc = null;
1822+
useMacroTask = false;
18121823
}
18131824

18141825
/**
@@ -1832,10 +1843,12 @@ function nextTick (cb, ctx) {
18321843
});
18331844
if (!pending) {
18341845
pending = true;
1835-
if (useMacroTask) {
1846+
if (useMacroTask && typeof macroTimerFunc === 'function') {
18361847
macroTimerFunc();
1837-
} else {
1848+
} else if (typeof microTimerFunc === 'function') {
18381849
microTimerFunc();
1850+
} else {
1851+
setTimeout(flushCallbacks, 0);
18391852
}
18401853
}
18411854
// $flow-disable-line
@@ -7245,6 +7258,43 @@ function watchArray (vm, array) {
72457258

72467259
var RecycleList = {
72477260
name: 'recycle-list',
7261+
methods: {
7262+
closest: function closest () {
7263+
var args = [], len = arguments.length;
7264+
while ( len-- ) args[ len ] = arguments[ len ];
7265+
7266+
return (ref = this.$el).closest.apply(ref, args)
7267+
var ref;
7268+
},
7269+
queryElement: function queryElement () {
7270+
var args = [], len = arguments.length;
7271+
while ( len-- ) args[ len ] = arguments[ len ];
7272+
7273+
return (ref = this.$el).queryElement.apply(ref, args)
7274+
var ref;
7275+
},
7276+
queryElementAll: function queryElementAll () {
7277+
var args = [], len = arguments.length;
7278+
while ( len-- ) args[ len ] = arguments[ len ];
7279+
7280+
return (ref = this.$el).queryElementAll.apply(ref, args)
7281+
var ref;
7282+
},
7283+
scrollToElement: function scrollToElement () {
7284+
var args = [], len = arguments.length;
7285+
while ( len-- ) args[ len ] = arguments[ len ];
7286+
7287+
return (ref = this.$el).scrollToElement.apply(ref, args)
7288+
var ref;
7289+
},
7290+
resetLoadmore: function resetLoadmore () {
7291+
var args = [], len = arguments.length;
7292+
while ( len-- ) args[ len ] = arguments[ len ];
7293+
7294+
return (ref = this.$el).resetLoadmore.apply(ref, args)
7295+
var ref;
7296+
}
7297+
},
72487298
render: function render (h) {
72497299
var this$1 = this;
72507300

@@ -7273,9 +7323,6 @@ var RecycleList = {
72737323
this._events['_attach_slot'] = function (instance) {
72747324
registerListRef(this$1.$parent || this$1, instance.position, instance.refs);
72757325
};
7276-
this._events['_update_slot'] = function (instance) {
7277-
registerListRef(this$1.$parent || this$1, instance.position, instance.refs);
7278-
};
72797326
this._events['_detach_slot'] = function (instance) {
72807327
registerListRef(this$1.$parent || this$1, instance.position, instance.refs, true);
72817328
};
@@ -7776,6 +7823,32 @@ function query (el, document) {
77767823
}
77777824

77787825
/* */
7826+
/**
7827+
* Internal mixin of Weex.
7828+
*/
7829+
function isRootComponent (vm) {
7830+
return !!(vm.$options && vm.$options.el)
7831+
}
7832+
7833+
var internalMixin = {
7834+
beforeCreate: function beforeCreate () {
7835+
// only affect root component
7836+
if (isRootComponent(this)) {
7837+
initTimerFunc();
7838+
}
7839+
},
7840+
destroyed: function destroyed () {
7841+
// only affect root component
7842+
if (isRootComponent(this)) {
7843+
resetTimerFunc();
7844+
}
7845+
}
7846+
};
7847+
7848+
/* */
7849+
7850+
// register internal mixin
7851+
Vue$2.mixin(internalMixin);
77797852

77807853
// install platform specific utils
77817854
Vue$2.config.mustUseProp = mustUseProp;

packages/weex-vue-framework/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "weex-vue-framework",
3-
"version": "2.5.16-weex.1",
3+
"version": "2.5.16-weex.5",
44
"description": "Vue 2.0 Framework for Weex",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)