mootools .get("text") checks

Benchmark created on


Description

Optimising the text getter

Preparation HTML

<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<script type="text/javascript" src="http://youli.st/js/libs/mootools-core-1.4.0.js" defer="defer"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
pre-cached
var properties = {};
Array.forEach([
    'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
    'frameBorder', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'
    ], function(property) {
    properties[property.toLowerCase()] = property;
});

var textGetter;

(function() {
    var temp = document.createElement('div');
    textGetter = temp.innerText == null ? 'textContent' : 'innerText';
})();

Object.append(properties, {
    'html': 'innerHTML',
    'text': (function() {
        return textGetter;
    })()
});

document.getElements("div.tag").get("text");
ready
standard on the fly check
var properties = {};
Array.forEach([
    'type', 'value', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan',
    'frameBorder', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'
    ], function(property) {
    properties[property.toLowerCase()] = property;
});

Object.append(properties, {
    'html': 'innerHTML',
    'text': (function() {
        var temp = document.createElement('div');
        return (temp.innerText == null) ? 'textContent' : 'innerText';
    })()
});

document.getElements("div.tag").get("text");
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.