This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
anot.js
Archived
1
0
Fork 0
anot.js/src/24-:text.js

17 lines
417 B
JavaScript
Raw Permalink Normal View History

2018-08-04 16:26:50 +08:00
Anot.directive('text', {
update: function(val) {
var elem = this.element
val = val == null ? '' : val //不在页面上显示undefined null
if (elem.nodeType === 3) {
//绑定在文本节点上
try {
//IE对游离于DOM树外的节点赋值会报错
elem.data = val
} catch (e) {}
} else {
//绑定在特性节点上
elem.textContent = val
}
}
})