nl_tokens: Make array observable
pl_tokens: function makeArrayObservable ( arr , observer , proxyArrApis ) { // Here, not using __proto__ implementation, there are two import reasons: // First, considering __proto__ will be deprecated and is not recommended to use // Second, some plugins like weixin contact plugin will change array definition, // the array instance __proto__ property does not contains any like `push` // `pop` API, and these API only existed in the instance context. // So, like the code as the following will not work correctly, // a = []; // a.__proto__.push is not defined, a.push is defined // a.__proto__.push = function () {}; // a.push(2); // always call the native push, not the override push method // Therefor, using __proto__ to proxy the array method will not work Object . keys ( proxyArrApis ) . forEach ( method => { let rawMethod = arr [ method ] ; arr [ <mask> ] = proxyArrApis [ method ] . bind ( arr , observer , rawMethod ) ; } ) ; arr . setItem = updateArrayItem . bind ( arr , observer ) ; arr . getItem = getArrayItem . bind ( arr , observer ) ; return arr ; }