Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9248988

Browse files
IgorMinarrodyhaddad
authored andcommitted
perf(jqLite): improve performance of jqLite#text
This change is not compatible with IE8.
1 parent ea230ea commit 9248988

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/jqLite.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -591,23 +591,15 @@ forEach({
591591
},
592592

593593
text: (function() {
594-
var NODE_TYPE_TEXT_PROPERTY = [];
595-
if (msie < 9) {
596-
NODE_TYPE_TEXT_PROPERTY[1] = 'innerText'; /** Element **/
597-
NODE_TYPE_TEXT_PROPERTY[3] = 'nodeValue'; /** Text **/
598-
} else {
599-
NODE_TYPE_TEXT_PROPERTY[1] = /** Element **/
600-
NODE_TYPE_TEXT_PROPERTY[3] = 'textContent'; /** Text **/
601-
}
602594
getText.$dv = '';
603595
return getText;
604596

605597
function getText(element, value) {
606-
var textProp = NODE_TYPE_TEXT_PROPERTY[element.nodeType];
607598
if (isUndefined(value)) {
608-
return textProp ? element[textProp] : '';
599+
var nodeType = element.nodeType;
600+
return (nodeType === 1 || nodeType === 3) ? element.textContent : '';
609601
}
610-
element[textProp] = value;
602+
element.textContent = value;
611603
}
612604
})(),
613605

0 commit comments

Comments
 (0)