Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/mip-bind/mip-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -88,6 +100,7 @@ define(function (require) {
m: window.m ? window.m : {}
};
MIP.$set(this._dataSource.m);
return this;
};

/**
Expand Down Expand Up @@ -119,6 +132,7 @@ define(function (require) {
}
});
};

return new Bind().start();
var bindInstance = new Bind().start();
window.reBindDom = bindInstance.reBindDom.bind(bindInstance);
return bindInstance;
});
14 changes: 12 additions & 2 deletions src/mip-list/mip-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 获取模板]
*
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mip-mustache/sanitizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:',
Expand Down