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

Commit

Permalink
perf(jqLite): improve performance of jqLite#text
Browse files Browse the repository at this point in the history
This change is not compatible with IE8.
  • Loading branch information
IgorMinar authored and rodyhaddad committed Jun 13, 2014
1 parent ea230ea commit 9248988
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,23 +591,15 @@ forEach({
},

text: (function() {
var NODE_TYPE_TEXT_PROPERTY = [];
if (msie < 9) {
NODE_TYPE_TEXT_PROPERTY[1] = 'innerText'; /** Element **/
NODE_TYPE_TEXT_PROPERTY[3] = 'nodeValue'; /** Text **/
} else {
NODE_TYPE_TEXT_PROPERTY[1] = /** Element **/
NODE_TYPE_TEXT_PROPERTY[3] = 'textContent'; /** Text **/
}
getText.$dv = '';
return getText;

function getText(element, value) {
var textProp = NODE_TYPE_TEXT_PROPERTY[element.nodeType];
if (isUndefined(value)) {
return textProp ? element[textProp] : '';
var nodeType = element.nodeType;
return (nodeType === 1 || nodeType === 3) ? element.textContent : '';
}
element[textProp] = value;
element.textContent = value;
}
})(),

Expand Down

0 comments on commit 9248988

Please sign in to comment.