Skip to content

Commit

Permalink
chore: publish [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanks10100 committed Sep 26, 2018
1 parent 4f47f41 commit 9cb3a47
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 47 deletions.
165 changes: 119 additions & 46 deletions packages/weex-vue-framework/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -1766,49 +1766,60 @@ var microTimerFunc;
var macroTimerFunc;
var useMacroTask = false;

// Determine (macro) task defer implementation.
// Technically setImmediate should be the ideal choice, but it's only available
// in IE. The only polyfill that consistently queues the callback after all DOM
// events triggered in the same loop is by using MessageChannel.
/* istanbul ignore if */
if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
macroTimerFunc = function () {
setImmediate(flushCallbacks);
};
} else if (typeof MessageChannel !== 'undefined' && (
isNative(MessageChannel) ||
// PhantomJS
MessageChannel.toString() === '[object MessageChannelConstructor]'
)) {
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = flushCallbacks;
macroTimerFunc = function () {
port.postMessage(1);
};
} else {
/* istanbul ignore next */
macroTimerFunc = function () {
setTimeout(flushCallbacks, 0);
};
function initTimerFunc () {
// Determine (macro) task defer implementation.
// Technically setImmediate should be the ideal choice, but it's only available
// in IE. The only polyfill that consistently queues the callback after all DOM
// events triggered in the same loop is by using MessageChannel.
/* istanbul ignore if */
if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
macroTimerFunc = function () {
setImmediate(flushCallbacks);
};
} else if (typeof MessageChannel !== 'undefined' && (
isNative(MessageChannel) ||
// PhantomJS
MessageChannel.toString() === '[object MessageChannelConstructor]'
)) {
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = flushCallbacks;
macroTimerFunc = function () {
port.postMessage(1);
};
} else {
/* istanbul ignore next */
macroTimerFunc = function () {
setTimeout(flushCallbacks, 0);
};
}

// Determine microtask defer implementation.
/* istanbul ignore next, $flow-disable-line */
if (typeof Promise !== 'undefined' && isNative(Promise)) {
var p = Promise.resolve();
microTimerFunc = function () {
p.then(flushCallbacks);
// in problematic UIWebViews, Promise.then doesn't completely break, but
// it can get stuck in a weird state where callbacks are pushed into the
// microtask queue but the queue isn't being flushed, until the browser
// needs to do some other work, e.g. handle a timer. Therefore we can
// "force" the microtask queue to be flushed by adding an empty timer.
if (!inWeex && isIOS) { setTimeout(noop); }
};
} else {
// fallback to macro
microTimerFunc = macroTimerFunc;
}
}
initTimerFunc();

// Determine microtask defer implementation.
/* istanbul ignore next, $flow-disable-line */
if (typeof Promise !== 'undefined' && isNative(Promise)) {
var p = Promise.resolve();
microTimerFunc = function () {
p.then(flushCallbacks);
// in problematic UIWebViews, Promise.then doesn't completely break, but
// it can get stuck in a weird state where callbacks are pushed into the
// microtask queue but the queue isn't being flushed, until the browser
// needs to do some other work, e.g. handle a timer. Therefore we can
// "force" the microtask queue to be flushed by adding an empty timer.
if (isIOS) { setTimeout(noop); }
};
} else {
// fallback to macro
microTimerFunc = macroTimerFunc;
function resetTimerFunc () {
callbacks.length = 0;
pending = false;
microTimerFunc = null;
macroTimerFunc = null;
useMacroTask = false;
}

/**
Expand All @@ -1832,10 +1843,12 @@ function nextTick (cb, ctx) {
});
if (!pending) {
pending = true;
if (useMacroTask) {
if (useMacroTask && typeof macroTimerFunc === 'function') {
macroTimerFunc();
} else {
} else if (typeof microTimerFunc === 'function') {
microTimerFunc();
} else {
setTimeout(flushCallbacks, 0);
}
}
// $flow-disable-line
Expand Down Expand Up @@ -7245,6 +7258,43 @@ function watchArray (vm, array) {

var RecycleList = {
name: 'recycle-list',
methods: {
closest: function closest () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return (ref = this.$el).closest.apply(ref, args)
var ref;
},
queryElement: function queryElement () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return (ref = this.$el).queryElement.apply(ref, args)
var ref;
},
queryElementAll: function queryElementAll () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return (ref = this.$el).queryElementAll.apply(ref, args)
var ref;
},
scrollToElement: function scrollToElement () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return (ref = this.$el).scrollToElement.apply(ref, args)
var ref;
},
resetLoadmore: function resetLoadmore () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

return (ref = this.$el).resetLoadmore.apply(ref, args)
var ref;
}
},
render: function render (h) {
var this$1 = this;

Expand Down Expand Up @@ -7273,9 +7323,6 @@ var RecycleList = {
this._events['_attach_slot'] = function (instance) {
registerListRef(this$1.$parent || this$1, instance.position, instance.refs);
};
this._events['_update_slot'] = function (instance) {
registerListRef(this$1.$parent || this$1, instance.position, instance.refs);
};
this._events['_detach_slot'] = function (instance) {
registerListRef(this$1.$parent || this$1, instance.position, instance.refs, true);
};
Expand Down Expand Up @@ -7776,6 +7823,32 @@ function query (el, document) {
}

/* */
/**
* Internal mixin of Weex.
*/
function isRootComponent (vm) {
return !!(vm.$options && vm.$options.el)
}

var internalMixin = {
beforeCreate: function beforeCreate () {
// only affect root component
if (isRootComponent(this)) {
initTimerFunc();
}
},
destroyed: function destroyed () {
// only affect root component
if (isRootComponent(this)) {
resetTimerFunc();
}
}
};

/* */

// register internal mixin
Vue$2.mixin(internalMixin);

// install platform specific utils
Vue$2.config.mustUseProp = mustUseProp;
Expand Down
2 changes: 1 addition & 1 deletion packages/weex-vue-framework/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "weex-vue-framework",
"version": "2.5.16-weex.1",
"version": "2.5.16-weex.5",
"description": "Vue 2.0 Framework for Weex",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 9cb3a47

Please sign in to comment.