diff --git a/src/mip-bind/mip-bind.js b/src/mip-bind/mip-bind.js index ab03a206e..01f8a5e6c 100644 --- a/src/mip-bind/mip-bind.js +++ b/src/mip-bind/mip-bind.js @@ -59,6 +59,18 @@ define(function (require) { } }; + + /** + * rebind dom + * + */ + Bind.prototype.reBindDom = function(dom){ + var oriDom = this._compile._el;; + this._compile._el = dom || oriDom; + this._compile.start(this._win.m); + this._compile._el = oriDom; + } + /** * Bind event for post message when fetch data returned, then compile dom again * @@ -88,6 +100,7 @@ define(function (require) { m: window.m ? window.m : {} }; MIP.$set(this._dataSource.m); + return this; }; /** @@ -119,6 +132,7 @@ define(function (require) { } }); }; - - return new Bind().start(); + var bindInstance = new Bind().start(); + window.reBindDom = bindInstance.reBindDom.bind(bindInstance); + return bindInstance; }); diff --git a/src/mip-list/mip-list.js b/src/mip-list/mip-list.js index b392c4228..e49a5cc5e 100644 --- a/src/mip-list/mip-list.js +++ b/src/mip-list/mip-list.js @@ -8,7 +8,9 @@ define(function (require) { var customElement = require('customElement').create(); var templates = require('templates'); var fetchJsonp = require('fetch-jsonp'); - + var bind = null; + // 禁止提前依赖 + var _require = require; /** * [renderTemplate 获取模板] * @@ -33,14 +35,22 @@ define(function (require) { */ function render(htmls) { var self = this; + var fragment = document.createDocumentFragment(); + if (!bind) { + bind = window.m ? _require('mip-bind') : null; + } + htmls.map(function (html) { var node = document.createElement('div'); node.innerHTML = html; node.setAttribute('role', 'listitem'); - fragment.appendChild(node); }); + + if (bind) { + bind && bind.reBindDom(fragment); + } self.container.appendChild(fragment); } diff --git a/src/mip-mustache/sanitizer.js b/src/mip-mustache/sanitizer.js index 2c32f2671..1ca2ef962 100644 --- a/src/mip-mustache/sanitizer.js +++ b/src/mip-mustache/sanitizer.js @@ -62,7 +62,7 @@ define(function (require) { 'u' ]; - var WHITELISTED_ATTR_PREFIX_REGEX = /^data-/i; + var WHITELISTED_ATTR_PREFIX_REGEX = /^((data-)|(m-))/i; var BLACKLISTED_ATTR_VALUES = [ 'javascript:',