diff --git a/dist/nuclear.js b/dist/nuclear.js
index be0a44b5d..b407aa0a6 100644
--- a/dist/nuclear.js
+++ b/dist/nuclear.js
@@ -61,7 +61,7 @@ Nuclear._mixObj = function (obj) {
parent: this.parent
};
this._nuclearRender(this._nuclearRenderInfo);
-
+ if (this.installed) this.installed();
}
//加if防止子类赋值undefined,丢失父类方法
@@ -104,7 +104,7 @@ Nuclear._mixObj = function (obj) {
this._nuclearId = Nuclear.getId()
this.node.setAttribute("data-nuclearId", this._nuclearId);
if (this.onRefresh) this.onRefresh();
- if (this.installed) this.installed();
+
item.refreshPart = this.node.querySelectorAll('*[nc-refresh]');
this.HTML = this.node.outerHTML;
@@ -141,6 +141,10 @@ Nuclear._mixObj = function (obj) {
}
obj._nuclearLocalRefresh = function () {
+ if (this.update) {
+ this.update();
+ return;
+ }
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
item.tpl = this._nuclearTplGenerator();
diff --git a/dist/nuclear.min.js b/dist/nuclear.min.js
index 95348384e..cadd81ec7 100644
--- a/dist/nuclear.min.js
+++ b/dist/nuclear.min.js
@@ -3,4 +3,4 @@
* Github: https://github.com/AlloyTeam/Nuclear
* MIT Licensed.
*/
-!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():"function"==typeof define&&define.cmd?define(function(t,n,r){r.exports=e()}):t.Nuclear=e()}(this,function(){var t={};return t.create=function(e){return t._mixObj(e),e.statics||(e.statics={}),e.statics.create=function(e){return t._mixObj(e),this.extend(e)},t.Class.extend(e)},t._mixObj=function(e){e.ctor=function(e,n){this._nuclearParentEmpty=!n,this.HTML="",this.option=e,this.parent=this._nuclearParentEmpty?document.createElement("div"):"string"==typeof n?document.querySelector(n):n,this.install&&this.install(),this._nuclearRef=[];for(var r in this)this.hasOwnProperty(r)&&this[r]&&this[r]._nuclearLocalRefresh&&(this[r]._nuclearParent=this,this._nuclearRef.push(this[r]));this.option&&t.observe(this.option,t.throttle(this._nuclearLocalRefresh.bind(this),40)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this._nuclearRender(this._nuclearRenderInfo)},e.render&&(e._nuclearTplGenerator=e.render),e.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},e._nuclearRender=function(e){if(this.node){var n=t.str2Dom(t.Tpl.render(e.tpl,e.data));e.parent.replaceChild(n,this.node),this.node=n}else e.parent.insertAdjacentHTML("beforeEnd",t.Tpl.render(e.tpl,e.data)),this.node=e.parent.lastChild;this._nuclearId=t.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this.onRefresh&&this.onRefresh(),this.installed&&this.installed(),e.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix()},e._nuclearFix=function(){if(!this._nuclearParent){var t=this._nuclearGetTop(this);this._nuclearFixOne(t)}},e._nuclearFixOne=function(t){var e=t._nuclearRef.length;if(e>0)for(var n=0;e>n;n++){var r=t._nuclearRef[n];r.node=t.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,r.onRefresh&&r.onRefresh(),r.installed&&r.installed(),this._nuclearFixOne(r)}},e._nuclearGetTop=function(t){return t._nuclearParent?this._nuclearGetTop(t._nuclearParent):t},e._nuclearLocalRefresh=function(){var e=this._nuclearRenderInfo,n=e.refreshPart.length;if(e.tpl=this._nuclearTplGenerator(),n>0){for(var r=t.str2Dom(t.Tpl.render(e.tpl,e.data)).querySelectorAll("*[nc-refresh]"),o=0;n>o;o++){var i=e.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}e.refreshPart=r,this.onRefresh&&this.onRefresh(),this.HTML=this.node.outerHTML,this._nuclearFix()}else this._nuclearRender(e)}},t._minActionObj=function(t){t.ctor=function(t){this.option=t,this.install&&this.install()}},t.createAction=function(e){return t._minActionObj(e),e.statics||(e.statics={}),e.statics.createAction=function(e){return t._minActionObj(e),this.extend(e)},t.Class.extend(e)},t.throttle=function(t,e,n){var r,o,i,s=null,a=0;n||(n={});var c=function(){a=n.leading===!1?0:Date.now(),s=null,i=t.apply(r,o),s||(r=o=null)};return function(){var l=Date.now();a||n.leading!==!1||(a=l);var u=e-(l-a);return r=this,o=arguments,0>=u||u>e?(clearTimeout(s),s=null,a=l,i=t.apply(r,o),s||(r=o=null)):s||n.trailing===!1||(s=setTimeout(c,u)),i}},t.isElement=function(t){return"object"==typeof HTMLElement?t instanceof HTMLElement:t&&"object"==typeof t&&null!==t&&1===t.nodeType&&"string"==typeof t.nodeName},t.str2Dom=function(t){var e={option:[1,""],legend:[1,"
"],area:[1,""],param:[1,""],thead:[1,""],tr:[2,""],col:[2,""],td:[3,""],body:[0,"",""],_default:[1,"","
"]};e.optgroup=e.option,e.tbody=e.tfoot=e.colgroup=e.caption=e.thead,e.th=e.td;var n=/<\s*\w.*?>/g.exec(t),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=(document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null),document.createElement("body"));r.innerHTML=t.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=t;for(var a=0;a=0?t.removeClass(e,n):t.addClass(e,n)},t.trim=function(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},t._iteration=function(e,n){var n=Array.prototype.slice.call(n);t.each(n[0],function(r){var o=n[0];n[0]=n[0][r],t[e].apply(t,n),n[0]=o})},t.css=function(e,n,r){return e?t.isNodeList(e)?void t._iteration("css",arguments):(3==arguments.length&&e.style&&(e.style[n]=r),window.getComputedStyle(e,null)[n]):void 0},t.each=function(t,e){for(var n=0,r=t.length;r>n;n++)e.call(t[n],n)},t.offset=function(t){var e=0,n=0;if(!document.documentElement.getBoundingClientRect||!t.getBoundingClientRect){for(;t.offsetParent;)e+=t.offsetTop,n+=t.offsetLeft,t=t.offsetParent;return{left:n,top:e}}var r=t.getBoundingClientRect();return n=r.left,e=r.top,{left:n+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),top:e+Math.max(document.documentElement.scrollTop,document.body.scrollTop)}},t.getViewport=function(){var t=document.documentElement,e=document.body,n=window,r=document.createElement("div");r.innerHTML=" ";var o=3!==r.firstChild.nodeType?{left:e.scrollLeft||t.scrollLeft,top:e.scrollTop||t.scrollTop}:{left:n.pageXOffset,top:n.pageYOffset},i=n.innerWidth?{width:n.innerWidth,height:n.innerHeight}:t&&t.clientWidth&&0!=t.clientWidth?{width:t.clientWidth,height:t.clientHeight}:{width:e.clientWidth,height:e.clientHeight};return{left:o.left,top:o.top,width:i.width,height:i.height}},t.getLastNode=function(t,e){var n=t.querySelectorAll(e),r=n.length;return n[r-1]},t.isUndefined=function(t){return"undefined"==typeof t},t.domready=function(){var t,e=[],n=document,r=n.documentElement.doScroll,o="DOMContentLoaded",i=(r?/^loaded|^c/:/^loaded|^i|^c/).test(n.readyState);return i||n.addEventListener(o,t=function(){for(n.removeEventListener(o,t),i=1;t=e.shift();)t()}),function(t){i?setTimeout(t,0):e.push(t)}}(),function(){var e={},n=Object.prototype.toString;"Boolean Number String Function Array Date RegExp Object Error NodeList".split(" ").forEach(function(t){e["[object "+t+"]"]=t.toLowerCase()});var r=function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?e[n.call(t)]||"object":typeof t},o=function(t){return"nodelist"===r(t)},i=function(t){return"function"===r(t)},s=function(t){return"array"===r(t)},a=function(t){return null!=t&&t===t.window},c=function(t){return"object"!==r(t)||t.nodeType||a(t)?!1:t.constructor&&!hasOwn.call(t.constructor.prototype,"isPrototypeOf")?!1:!0};t.type=r,t.isFunction=i,t.isArray=s,t.isWindow=a,t.isPlainObject=c,t.isNodeList=o}(),t.merge=function(){var e,n,r,o,i,s,a=arguments[0]||{},c=1,l=arguments.length,u=!1;for("boolean"==typeof a&&(u=a,a=arguments[c]||{},c++),"object"==typeof a||t.isFunction(a)||(a={}),c===l&&(a=this,c--);l>c;c++)if(null!=(e=arguments[c]))for(n in e)r=a[n],o=e[n],a!==o&&(u&&o&&(t.isPlainObject(o)||(i=t.isArray(o)))?(i?(i=!1,s=r&&t.isArray(r)?r:[]):s=r&&t.isPlainObject(r)?r:{},a[n]=t.merge(u,s,o)):void 0!==o&&(a[n]=o));return a},t.uuid=function(){var t=(new Date).getTime(),e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:3&n|8).toString(16)});return e},t.createCanvas=function(e){return t._minCanvasObj(e),e.statics||(e.statics={}),e.statics.create=function(e){return t._minCanvasObj(e),this.extend(e)},t.Class.extend(e)},t._minCanvasObj=function(e){e.ctor=function(e,n,r,o){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.canvas.width=e,this.canvas.height=n,this.parent="string"==typeof o?document.querySelector(o):o,this.option=r,this.install&&this.install(),this.option&&t.observe(this.option,t.throttle(this._nuclearRender.bind(this),15)),this._nuclearRender(),this.installed&&this.installed(),this.parent.appendChild(this.canvas)},e._nuclearRender=function(t){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.render()}},t._nextID=0,t.getId=function(){return t._nextID++},function(e,n){t.Tpl={},n(t.Tpl)}(this,function(t){function e(t){return"function"==typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r(t,e){return d.call(t,e)}function o(t){return!r(v,t)}function i(t){return String(t).replace(/[&<>"'\/]/g,function(t){return g[t]})}function s(e,r){function i(){if(_&&!P)for(;g.length;)delete v[g.pop()];else g=[];_=!1,P=!1}function s(t){if("string"==typeof t&&(t=t.split(m,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);u=new RegExp(n(t[0])+"\\s*"),h=new RegExp("\\s*"+n(t[1])),f=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var u,h,f,d=[],v=[],g=[],_=!1,P=!1;s(r||t.tags);for(var C,T,E,j,O,R,A=new l(e);!A.eos();){if(C=A.pos,E=A.scanUntil(u))for(var L=0,$=E.length;$>L;++L)j=E.charAt(L),o(j)?g.push(v.length):P=!0,v.push(["text",j,C,C+1]),C+=1,"\n"===j&&i();if(!A.scan(u))break;if(_=!0,T=A.scan(w)||"name",A.scan(y),"="===T?(E=A.scanUntil(b),A.scan(b),A.scanUntil(h)):"{"===T?(E=A.scanUntil(f),A.scan(x),A.scanUntil(h),T="&"):E=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(O=[T,E,C,A.pos],v.push(O),"#"===T||"^"===T)d.push(O);else if("/"===T){if(R=d.pop(),!R)throw new Error('Unopened section "'+E+'" at '+C);if(R[1]!==E)throw new Error('Unclosed section "'+R[1]+'" at '+C)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(E)}if(R=d.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(t){for(var e,n,r=[],o=0,i=t.length;i>o;++o)e=t[o],e&&("text"===e[0]&&n&&"text"===n[0]?(n[1]+=e[1],n[3]=e[3]):(r.push(e),n=e));return r}function c(t){for(var e,n,r=[],o=r,i=[],s=0,a=t.length;a>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),i.push(e),o=e[4]=[];break;case"/":n=i.pop(),n[5]=e[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(e)}return r}function l(t){this.string=t,this.tail=t,this.pos=0}function u(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function h(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},d=RegExp.prototype.test,v=/\S/,g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},y=/\s*/,m=/\s+/,b=/\s*=/,x=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var n=e[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(t){var e,n=this.tail.search(t);switch(n){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=e.length,e},u.prototype.push=function(t){return new u(t,this)},u.prototype.lookup=function(t){var n,r=this.cache;if(t in r)n=r[t];else{for(var o,i,s=this,a=!1;s;){if(t.indexOf(".")>0)for(n=s.view,o=t.split("."),i=0;null!=n&⁣++c)s=void 0,o=t[c],i=o[0],"#"===i?s=this.renderSection(o,e,n,r):"^"===i?s=this.renderInverted(o,e,n,r):">"===i?s=this.renderPartial(o,e,n,r):"&"===i?s=this.unescapedValue(o,e):"name"===i?s=this.escapedValue(o,e):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(t,n,r,o){function i(t){return s.render(t,n,r)}var s=this,a="",c=n.lookup(t[1]);if(c){if(p(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(t[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(t[4],n.push(c),r,o);else if(e(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(t[3],t[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(t[4],n,r,o);return a}},h.prototype.renderInverted=function(t,e,n,r){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,n,r):void 0},h.prototype.renderPartial=function(t,n,r){if(r){var o=e(r)?r(t[1]):r[t[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(t,e){var n=e.lookup(t[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(e,n){var r=n.lookup(e[1]);return null!=r?t.escape(r):void 0},h.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.0.0",t.tags=["{{","}}"];var _=new h;t.clearCache=function(){return _.clearCache()},t.parse=function(t,e){return _.parse(t,e)},t.render=function(t,e,n){return _.render(t,e,n)},t.to_html=function(n,r,o,i){var s=t.render(n,r,o);return e(i)?void i(s):s},t.escape=i,t.Scanner=l,t.Context=u,t.Writer=h}),function(){var e=function(t,n,r){var o=function(t,n,r){t.$observer||(t.$observer=this);var o=t.$observer,i=[];e.isArray(t)&&(0===t.length&&(t.$observeProps={},t.$observeProps.$observerPath="#"),o.mock(t));for(var s in t)t.hasOwnProperty(s)&&(r?e.isArray(n)&&e.isInArray(n,s)?(i.push(s),o.watch(t,s)):e.isString(n)&&s==n&&(i.push(s),o.watch(t,s)):(i.push(s),o.watch(t,s)));o.target=t,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(t,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=e._getRootName(t,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||e.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,t,n,r,i)}0!==t.indexOf("Array-")&&"object"==typeof n&&this.watch(o,t,o.$observeProps.$observerPath)},mock:function(t){var n=this;e.methods.forEach(function(r){t[r]=function(){var t=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(e.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!e.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,t,this,this.$observeProps.$observerPath)}return o}})},watch:function(t,n,r){if("$observeProps"!==n&&"$observer"!==n&&!e.isFunction(t[n])){t.$observeProps||(t.$observeProps={}),t.$observeProps.$observerPath=void 0!==r?r:"#";var o=this,i=t.$observeProps[n]=t[n];if(Object.defineProperty(t,n,{get:function(){return this.$observeProps[n]},set:function(e){var r=this.$observeProps[n];this.$observeProps[n]=e,o.onPropertyChanged(n,e,r,this,t.$observeProps.$observerPath)}}),"object"==typeof i){e.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),i.$observeProps.$observerPath=void 0!==r?r:"#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,t.$observeProps.$observerPath+"-"+n)}}}},new o(t,n,r)};e.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],e.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isInArray=function(t,e){for(var n=t.length;--n>-1;)if(e===t[n])return!0;return!1},e.isFunction=function(t){return"[object Function]"==Object.prototype.toString.call(t)},e.twoWay=function(t,n,r,o){"object"==typeof t[n]&&"object"==typeof r[o]?(e(t,n,function(t,e){r[o]=this[n]}),e(r,o,function(e,r){t[n]=this[o]})):(e(t,n,function(t,e){r[o]=e}),e(r,o,function(e,r){t[n]=r}))},e._getRootName=function(t,e){return"#"===e?t:e.split("-")[1]},e.add=function(t,e,n){t[e]=n;var r=t.$observer;r.watch(t,e)},Array.prototype.size=function(t){this.length=t},t.observe=e}(),function(){var e=!1,n=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,r=function(){};r.extend=function(t){function o(){!e&&this.ctor&&this.ctor.apply(this,arguments)}var i=this.prototype;e=!0;var s=new this;e=!1;for(var a in t)"statics"!=a&&(s[a]="function"==typeof t[a]&&"function"==typeof i[a]&&n.test(t[a])?function(t,e){return function(){var n=this._super;this._super=i[t];var r=e.apply(this,arguments);return this._super=n,r}}(a,t[a]):t[a]);for(var c in this)this.hasOwnProperty(c)&&"extend"!=c&&(o[c]=this[c]);if(o.prototype=s,t.statics)for(var a in t.statics)t.statics.hasOwnProperty(a)&&(o[a]=t.statics[a],"ctor"==a&&o[a]());return o.prototype.constructor=o,o.extend=r.extend,o.implement=function(t){for(var e in t)s[e]=t[e]},o},t.Class=r}(),t});
\ No newline at end of file
+!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():"function"==typeof define&&define.cmd?define(function(t,n,r){r.exports=e()}):t.Nuclear=e()}(this,function(){var t={};return t.create=function(e){return t._mixObj(e),e.statics||(e.statics={}),e.statics.create=function(e){return t._mixObj(e),this.extend(e)},t.Class.extend(e)},t._mixObj=function(e){e.ctor=function(e,n){this._nuclearParentEmpty=!n,this.HTML="",this.option=e,this.parent=this._nuclearParentEmpty?document.createElement("div"):"string"==typeof n?document.querySelector(n):n,this.install&&this.install(),this._nuclearRef=[];for(var r in this)this.hasOwnProperty(r)&&this[r]&&this[r]._nuclearLocalRefresh&&(this[r]._nuclearParent=this,this._nuclearRef.push(this[r]));this.option&&t.observe(this.option,t.throttle(this._nuclearLocalRefresh.bind(this),40)),this._nuclearRenderInfo={tpl:this._nuclearTplGenerator(),data:this.option,parent:this.parent},this._nuclearRender(this._nuclearRenderInfo),this.installed&&this.installed()},e.render&&(e._nuclearTplGenerator=e.render),e.render=function(){return this._nuclearParentEmpty?this.HTML:this._nuclearTplGenerator()},e._nuclearRender=function(e){if(this.node){var n=t.str2Dom(t.Tpl.render(e.tpl,e.data));e.parent.replaceChild(n,this.node),this.node=n}else e.parent.insertAdjacentHTML("beforeEnd",t.Tpl.render(e.tpl,e.data)),this.node=e.parent.lastChild;this._nuclearId=t.getId(),this.node.setAttribute("data-nuclearId",this._nuclearId),this.onRefresh&&this.onRefresh(),e.refreshPart=this.node.querySelectorAll("*[nc-refresh]"),this.HTML=this.node.outerHTML,this._nuclearFix()},e._nuclearFix=function(){if(!this._nuclearParent){var t=this._nuclearGetTop(this);this._nuclearFixOne(t)}},e._nuclearFixOne=function(t){var e=t._nuclearRef.length;if(e>0)for(var n=0;e>n;n++){var r=t._nuclearRef[n];r.node=t.node.querySelector('*[data-nuclearId="'+r._nuclearId+'"]'),r._nuclearRenderInfo.refreshPart=r.node.querySelectorAll("*[nc-refresh]"),r._nuclearRenderInfo.parent=r.node.parentNode,r.onRefresh&&r.onRefresh(),r.installed&&r.installed(),this._nuclearFixOne(r)}},e._nuclearGetTop=function(t){return t._nuclearParent?this._nuclearGetTop(t._nuclearParent):t},e._nuclearLocalRefresh=function(){if(this.update)return void this.update();var e=this._nuclearRenderInfo,n=e.refreshPart.length;if(e.tpl=this._nuclearTplGenerator(),n>0){for(var r=t.str2Dom(t.Tpl.render(e.tpl,e.data)).querySelectorAll("*[nc-refresh]"),o=0;n>o;o++){var i=e.refreshPart[o];i.parentNode&&i.parentNode.replaceChild(r[o],i)}e.refreshPart=r,this.onRefresh&&this.onRefresh(),this.HTML=this.node.outerHTML,this._nuclearFix()}else this._nuclearRender(e)}},t._minActionObj=function(t){t.ctor=function(t){this.option=t,this.install&&this.install()}},t.createAction=function(e){return t._minActionObj(e),e.statics||(e.statics={}),e.statics.createAction=function(e){return t._minActionObj(e),this.extend(e)},t.Class.extend(e)},t.throttle=function(t,e,n){var r,o,i,s=null,a=0;n||(n={});var c=function(){a=n.leading===!1?0:Date.now(),s=null,i=t.apply(r,o),s||(r=o=null)};return function(){var l=Date.now();a||n.leading!==!1||(a=l);var u=e-(l-a);return r=this,o=arguments,0>=u||u>e?(clearTimeout(s),s=null,a=l,i=t.apply(r,o),s||(r=o=null)):s||n.trailing===!1||(s=setTimeout(c,u)),i}},t.isElement=function(t){return"object"==typeof HTMLElement?t instanceof HTMLElement:t&&"object"==typeof t&&null!==t&&1===t.nodeType&&"string"==typeof t.nodeName},t.str2Dom=function(t){var e={option:[1,""],legend:[1,""],area:[1,""],param:[1,""],thead:[1,""],tr:[2,""],col:[2,""],td:[3,""],body:[0,"",""],_default:[1,"","
"]};e.optgroup=e.option,e.tbody=e.tfoot=e.colgroup=e.caption=e.thead,e.th=e.td;var n=/<\s*\w.*?>/g.exec(t),r=document.createElement("div");if(null!=n){var o=n[0].replace(//g,"").split(" ")[0];if("body"===o.toLowerCase()){var i=(document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null),document.createElement("body"));r.innerHTML=t.replace(//g,"");var s=r.firstChild.attributes;i.innerHTML=t;for(var a=0;a=0?t.removeClass(e,n):t.addClass(e,n)},t.trim=function(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},t._iteration=function(e,n){var n=Array.prototype.slice.call(n);t.each(n[0],function(r){var o=n[0];n[0]=n[0][r],t[e].apply(t,n),n[0]=o})},t.css=function(e,n,r){return e?t.isNodeList(e)?void t._iteration("css",arguments):(3==arguments.length&&e.style&&(e.style[n]=r),window.getComputedStyle(e,null)[n]):void 0},t.each=function(t,e){for(var n=0,r=t.length;r>n;n++)e.call(t[n],n)},t.offset=function(t){var e=0,n=0;if(!document.documentElement.getBoundingClientRect||!t.getBoundingClientRect){for(;t.offsetParent;)e+=t.offsetTop,n+=t.offsetLeft,t=t.offsetParent;return{left:n,top:e}}var r=t.getBoundingClientRect();return n=r.left,e=r.top,{left:n+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),top:e+Math.max(document.documentElement.scrollTop,document.body.scrollTop)}},t.getViewport=function(){var t=document.documentElement,e=document.body,n=window,r=document.createElement("div");r.innerHTML=" ";var o=3!==r.firstChild.nodeType?{left:e.scrollLeft||t.scrollLeft,top:e.scrollTop||t.scrollTop}:{left:n.pageXOffset,top:n.pageYOffset},i=n.innerWidth?{width:n.innerWidth,height:n.innerHeight}:t&&t.clientWidth&&0!=t.clientWidth?{width:t.clientWidth,height:t.clientHeight}:{width:e.clientWidth,height:e.clientHeight};return{left:o.left,top:o.top,width:i.width,height:i.height}},t.getLastNode=function(t,e){var n=t.querySelectorAll(e),r=n.length;return n[r-1]},t.isUndefined=function(t){return"undefined"==typeof t},t.domready=function(){var t,e=[],n=document,r=n.documentElement.doScroll,o="DOMContentLoaded",i=(r?/^loaded|^c/:/^loaded|^i|^c/).test(n.readyState);return i||n.addEventListener(o,t=function(){for(n.removeEventListener(o,t),i=1;t=e.shift();)t()}),function(t){i?setTimeout(t,0):e.push(t)}}(),function(){var e={},n=Object.prototype.toString;"Boolean Number String Function Array Date RegExp Object Error NodeList".split(" ").forEach(function(t){e["[object "+t+"]"]=t.toLowerCase()});var r=function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?e[n.call(t)]||"object":typeof t},o=function(t){return"nodelist"===r(t)},i=function(t){return"function"===r(t)},s=function(t){return"array"===r(t)},a=function(t){return null!=t&&t===t.window},c=function(t){return"object"!==r(t)||t.nodeType||a(t)?!1:t.constructor&&!hasOwn.call(t.constructor.prototype,"isPrototypeOf")?!1:!0};t.type=r,t.isFunction=i,t.isArray=s,t.isWindow=a,t.isPlainObject=c,t.isNodeList=o}(),t.merge=function(){var e,n,r,o,i,s,a=arguments[0]||{},c=1,l=arguments.length,u=!1;for("boolean"==typeof a&&(u=a,a=arguments[c]||{},c++),"object"==typeof a||t.isFunction(a)||(a={}),c===l&&(a=this,c--);l>c;c++)if(null!=(e=arguments[c]))for(n in e)r=a[n],o=e[n],a!==o&&(u&&o&&(t.isPlainObject(o)||(i=t.isArray(o)))?(i?(i=!1,s=r&&t.isArray(r)?r:[]):s=r&&t.isPlainObject(r)?r:{},a[n]=t.merge(u,s,o)):void 0!==o&&(a[n]=o));return a},t.uuid=function(){var t=(new Date).getTime(),e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:3&n|8).toString(16)});return e},t.createCanvas=function(e){return t._minCanvasObj(e),e.statics||(e.statics={}),e.statics.create=function(e){return t._minCanvasObj(e),this.extend(e)},t.Class.extend(e)},t._minCanvasObj=function(e){e.ctor=function(e,n,r,o){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.canvas.width=e,this.canvas.height=n,this.parent="string"==typeof o?document.querySelector(o):o,this.option=r,this.install&&this.install(),this.option&&t.observe(this.option,t.throttle(this._nuclearRender.bind(this),15)),this._nuclearRender(),this.installed&&this.installed(),this.parent.appendChild(this.canvas)},e._nuclearRender=function(t){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.render()}},t._nextID=0,t.getId=function(){return t._nextID++},function(e,n){t.Tpl={},n(t.Tpl)}(this,function(t){function e(t){return"function"==typeof t}function n(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function r(t,e){return d.call(t,e)}function o(t){return!r(v,t)}function i(t){return String(t).replace(/[&<>"'\/]/g,function(t){return g[t]})}function s(e,r){function i(){if(_&&!P)for(;g.length;)delete v[g.pop()];else g=[];_=!1,P=!1}function s(t){if("string"==typeof t&&(t=t.split(m,2)),!p(t)||2!==t.length)throw new Error("Invalid tags: "+t);u=new RegExp(n(t[0])+"\\s*"),h=new RegExp("\\s*"+n(t[1])),f=new RegExp("\\s*"+n("}"+t[1]))}if(!e)return[];var u,h,f,d=[],v=[],g=[],_=!1,P=!1;s(r||t.tags);for(var C,T,E,j,O,R,A=new l(e);!A.eos();){if(C=A.pos,E=A.scanUntil(u))for(var L=0,$=E.length;$>L;++L)j=E.charAt(L),o(j)?g.push(v.length):P=!0,v.push(["text",j,C,C+1]),C+=1,"\n"===j&&i();if(!A.scan(u))break;if(_=!0,T=A.scan(w)||"name",A.scan(y),"="===T?(E=A.scanUntil(b),A.scan(b),A.scanUntil(h)):"{"===T?(E=A.scanUntil(f),A.scan(x),A.scanUntil(h),T="&"):E=A.scanUntil(h),!A.scan(h))throw new Error("Unclosed tag at "+A.pos);if(O=[T,E,C,A.pos],v.push(O),"#"===T||"^"===T)d.push(O);else if("/"===T){if(R=d.pop(),!R)throw new Error('Unopened section "'+E+'" at '+C);if(R[1]!==E)throw new Error('Unclosed section "'+R[1]+'" at '+C)}else"name"===T||"{"===T||"&"===T?P=!0:"="===T&&s(E)}if(R=d.pop())throw new Error('Unclosed section "'+R[1]+'" at '+A.pos);return c(a(v))}function a(t){for(var e,n,r=[],o=0,i=t.length;i>o;++o)e=t[o],e&&("text"===e[0]&&n&&"text"===n[0]?(n[1]+=e[1],n[3]=e[3]):(r.push(e),n=e));return r}function c(t){for(var e,n,r=[],o=r,i=[],s=0,a=t.length;a>s;++s)switch(e=t[s],e[0]){case"#":case"^":o.push(e),i.push(e),o=e[4]=[];break;case"/":n=i.pop(),n[5]=e[2],o=i.length>0?i[i.length-1][4]:r;break;default:o.push(e)}return r}function l(t){this.string=t,this.tail=t,this.pos=0}function u(t,e){this.view=t,this.cache={".":this.view},this.parent=e}function h(){this.cache={}}var f=Object.prototype.toString,p=Array.isArray||function(t){return"[object Array]"===f.call(t)},d=RegExp.prototype.test,v=/\S/,g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},y=/\s*/,m=/\s+/,b=/\s*=/,x=/\s*\}/,w=/#|\^|\/|>|\{|&|=|!/;l.prototype.eos=function(){return""===this.tail},l.prototype.scan=function(t){var e=this.tail.match(t);if(!e||0!==e.index)return"";var n=e[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n},l.prototype.scanUntil=function(t){var e,n=this.tail.search(t);switch(n){case-1:e=this.tail,this.tail="";break;case 0:e="";break;default:e=this.tail.substring(0,n),this.tail=this.tail.substring(n)}return this.pos+=e.length,e},u.prototype.push=function(t){return new u(t,this)},u.prototype.lookup=function(t){var n,r=this.cache;if(t in r)n=r[t];else{for(var o,i,s=this,a=!1;s;){if(t.indexOf(".")>0)for(n=s.view,o=t.split("."),i=0;null!=n&⁣++c)s=void 0,o=t[c],i=o[0],"#"===i?s=this.renderSection(o,e,n,r):"^"===i?s=this.renderInverted(o,e,n,r):">"===i?s=this.renderPartial(o,e,n,r):"&"===i?s=this.unescapedValue(o,e):"name"===i?s=this.escapedValue(o,e):"text"===i&&(s=this.rawValue(o)),void 0!==s&&(a+=s);return a},h.prototype.renderSection=function(t,n,r,o){function i(t){return s.render(t,n,r)}var s=this,a="",c=n.lookup(t[1]);if(c){if(p(c))for(var l=0,u=c.length;u>l;++l)a+=this.renderTokens(t[4],n.push(c[l]),r,o);else if("object"==typeof c||"string"==typeof c||"number"==typeof c)a+=this.renderTokens(t[4],n.push(c),r,o);else if(e(c)){if("string"!=typeof o)throw new Error("Cannot use higher-order sections without the original template");c=c.call(n.view,o.slice(t[3],t[5]),i),null!=c&&(a+=c)}else a+=this.renderTokens(t[4],n,r,o);return a}},h.prototype.renderInverted=function(t,e,n,r){var o=e.lookup(t[1]);return!o||p(o)&&0===o.length?this.renderTokens(t[4],e,n,r):void 0},h.prototype.renderPartial=function(t,n,r){if(r){var o=e(r)?r(t[1]):r[t[1]];return null!=o?this.renderTokens(this.parse(o),n,r,o):void 0}},h.prototype.unescapedValue=function(t,e){var n=e.lookup(t[1]);return null!=n?n:void 0},h.prototype.escapedValue=function(e,n){var r=n.lookup(e[1]);return null!=r?t.escape(r):void 0},h.prototype.rawValue=function(t){return t[1]},t.name="mustache.js",t.version="2.0.0",t.tags=["{{","}}"];var _=new h;t.clearCache=function(){return _.clearCache()},t.parse=function(t,e){return _.parse(t,e)},t.render=function(t,e,n){return _.render(t,e,n)},t.to_html=function(n,r,o,i){var s=t.render(n,r,o);return e(i)?void i(s):s},t.escape=i,t.Scanner=l,t.Context=u,t.Writer=h}),function(){var e=function(t,n,r){var o=function(t,n,r){t.$observer||(t.$observer=this);var o=t.$observer,i=[];e.isArray(t)&&(0===t.length&&(t.$observeProps={},t.$observeProps.$observerPath="#"),o.mock(t));for(var s in t)t.hasOwnProperty(s)&&(r?e.isArray(n)&&e.isInArray(n,s)?(i.push(s),o.watch(t,s)):e.isString(n)&&s==n&&(i.push(s),o.watch(t,s)):(i.push(s),o.watch(t,s)));o.target=t,o.propertyChangedHandler||(o.propertyChangedHandler=[]);var a=r?r:n;o.propertyChangedHandler.push({all:!r,propChanged:a,eventPropArr:i})};return o.prototype={onPropertyChanged:function(t,n,r,o,i){if(n!==r&&this.propertyChangedHandler)for(var s=e._getRootName(t,i),a=0,c=this.propertyChangedHandler.length;c>a;a++){var l=this.propertyChangedHandler[a];(l.all||e.isInArray(l.eventPropArr,s)||0===s.indexOf("Array-"))&&l.propChanged.call(this.target,t,n,r,i)}0!==t.indexOf("Array-")&&"object"==typeof n&&this.watch(o,t,o.$observeProps.$observerPath)},mock:function(t){var n=this;e.methods.forEach(function(r){t[r]=function(){var t=Array.prototype.slice.call(this,0),o=Array.prototype[r].apply(this,Array.prototype.slice.call(arguments));if(new RegExp("\\b"+r+"\\b").test(e.triggerStr)){for(var i in this)this.hasOwnProperty(i)&&!e.isFunction(this[i])&&n.watch(this,i,this.$observeProps.$observerPath);n.onPropertyChanged("Array-"+r,this,t,this,this.$observeProps.$observerPath)}return o}})},watch:function(t,n,r){if("$observeProps"!==n&&"$observer"!==n&&!e.isFunction(t[n])){t.$observeProps||(t.$observeProps={}),t.$observeProps.$observerPath=void 0!==r?r:"#";var o=this,i=t.$observeProps[n]=t[n];if(Object.defineProperty(t,n,{get:function(){return this.$observeProps[n]},set:function(e){var r=this.$observeProps[n];this.$observeProps[n]=e,o.onPropertyChanged(n,e,r,this,t.$observeProps.$observerPath)}}),"object"==typeof i){e.isArray(i)&&(this.mock(i),0===i.length&&(i.$observeProps||(i.$observeProps={}),i.$observeProps.$observerPath=void 0!==r?r:"#"));for(var s in i)i.hasOwnProperty(s)&&this.watch(i,s,t.$observeProps.$observerPath+"-"+n)}}}},new o(t,n,r)};e.methods=["concat","every","filter","forEach","indexOf","join","lastIndexOf","map","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","toLocaleString","toString","size"],e.triggerStr=["concat","pop","push","reverse","shift","sort","splice","unshift","size"].join(","),e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isInArray=function(t,e){for(var n=t.length;--n>-1;)if(e===t[n])return!0;return!1},e.isFunction=function(t){return"[object Function]"==Object.prototype.toString.call(t)},e.twoWay=function(t,n,r,o){"object"==typeof t[n]&&"object"==typeof r[o]?(e(t,n,function(t,e){r[o]=this[n]}),e(r,o,function(e,r){t[n]=this[o]})):(e(t,n,function(t,e){r[o]=e}),e(r,o,function(e,r){t[n]=r}))},e._getRootName=function(t,e){return"#"===e?t:e.split("-")[1]},e.add=function(t,e,n){t[e]=n;var r=t.$observer;r.watch(t,e)},Array.prototype.size=function(t){this.length=t},t.observe=e}(),function(){var e=!1,n=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,r=function(){};r.extend=function(t){function o(){!e&&this.ctor&&this.ctor.apply(this,arguments)}var i=this.prototype;e=!0;var s=new this;e=!1;for(var a in t)"statics"!=a&&(s[a]="function"==typeof t[a]&&"function"==typeof i[a]&&n.test(t[a])?function(t,e){return function(){var n=this._super;this._super=i[t];var r=e.apply(this,arguments);return this._super=n,r}}(a,t[a]):t[a]);for(var c in this)this.hasOwnProperty(c)&&"extend"!=c&&(o[c]=this[c]);if(o.prototype=s,t.statics)for(var a in t.statics)t.statics.hasOwnProperty(a)&&(o[a]=t.statics[a],"ctor"==a&&o[a]());return o.prototype.constructor=o,o.extend=r.extend,o.implement=function(t){for(var e in t)s[e]=t[e]},o},t.Class=r}(),t});
\ No newline at end of file
diff --git a/example/marquee.html b/example/marquee.html
new file mode 100644
index 000000000..2f58d9f7b
--- /dev/null
+++ b/example/marquee.html
@@ -0,0 +1,37 @@
+
+
+
+ Marquee
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/nuclear.js b/src/nuclear.js
index 6c4a2f374..90d2f2a15 100644
--- a/src/nuclear.js
+++ b/src/nuclear.js
@@ -42,7 +42,7 @@ Nuclear._mixObj = function (obj) {
parent: this.parent
};
this._nuclearRender(this._nuclearRenderInfo);
-
+ if (this.installed) this.installed();
}
//加if防止子类赋值undefined,丢失父类方法
@@ -85,7 +85,7 @@ Nuclear._mixObj = function (obj) {
this._nuclearId = Nuclear.getId()
this.node.setAttribute("data-nuclearId", this._nuclearId);
if (this.onRefresh) this.onRefresh();
- if (this.installed) this.installed();
+
item.refreshPart = this.node.querySelectorAll('*[nc-refresh]');
this.HTML = this.node.outerHTML;
@@ -122,6 +122,10 @@ Nuclear._mixObj = function (obj) {
}
obj._nuclearLocalRefresh = function () {
+ if (this.update) {
+ this.update();
+ return;
+ }
var item = this._nuclearRenderInfo, rpLen = item.refreshPart.length;
item.tpl = this._nuclearTplGenerator();