@@ -1766,49 +1766,60 @@ var microTimerFunc;
1766
1766
var macroTimerFunc ;
1767
1767
var useMacroTask = false ;
1768
1768
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
+ }
1794
1814
}
1815
+ initTimerFunc ( ) ;
1795
1816
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 ;
1812
1823
}
1813
1824
1814
1825
/**
@@ -1832,10 +1843,12 @@ function nextTick (cb, ctx) {
1832
1843
} ) ;
1833
1844
if ( ! pending ) {
1834
1845
pending = true ;
1835
- if ( useMacroTask ) {
1846
+ if ( useMacroTask && typeof macroTimerFunc === 'function' ) {
1836
1847
macroTimerFunc ( ) ;
1837
- } else {
1848
+ } else if ( typeof microTimerFunc === 'function' ) {
1838
1849
microTimerFunc ( ) ;
1850
+ } else {
1851
+ setTimeout ( flushCallbacks , 0 ) ;
1839
1852
}
1840
1853
}
1841
1854
// $flow-disable-line
@@ -7245,6 +7258,43 @@ function watchArray (vm, array) {
7245
7258
7246
7259
var RecycleList = {
7247
7260
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
+ } ,
7248
7298
render : function render ( h ) {
7249
7299
var this$1 = this ;
7250
7300
@@ -7273,9 +7323,6 @@ var RecycleList = {
7273
7323
this . _events [ '_attach_slot' ] = function ( instance ) {
7274
7324
registerListRef ( this$1 . $parent || this$1 , instance . position , instance . refs ) ;
7275
7325
} ;
7276
- this . _events [ '_update_slot' ] = function ( instance ) {
7277
- registerListRef ( this$1 . $parent || this$1 , instance . position , instance . refs ) ;
7278
- } ;
7279
7326
this . _events [ '_detach_slot' ] = function ( instance ) {
7280
7327
registerListRef ( this$1 . $parent || this$1 , instance . position , instance . refs , true ) ;
7281
7328
} ;
@@ -7776,6 +7823,32 @@ function query (el, document) {
7776
7823
}
7777
7824
7778
7825
/* */
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 ) ;
7779
7852
7780
7853
// install platform specific utils
7781
7854
Vue$2 . config . mustUseProp = mustUseProp ;
0 commit comments