var Feature = (function() { var tests = { DOCUMENT_GETELEMENTBYID_CONFUSES_IDS_WITH_NAMES: function() { // need to feature test all these DOM methods before calling them var num = Number(new Date()), name = '__test_' + num, head = document.getElementsByTagName('head')[0], isBuggy = false, el; try { el = document.createElement(''); } catch(e) { el = document.createElement('input'); el.name = name; } head.appendChild(el); var testElement = document.getElementById(name); isBuggy = !!(testElement && (testElement.nodeName.toUpperCase() === 'INPUT')); head.removeChild(el); el = null; return isBuggy; }, NEWLINES_IGNORED_AS_INNERHTML_OF_PRE_ELEMENT: function(){ var element = document.createElement('pre'), isIgnored = false; if (element) { element.innerHTML = 'a\nb'; isIgnored = (element.innerHTML.charAt(1) !== '\n'); element = null; } return isIgnored; }, STRING_PROTOTYPE_REPLACE_IGNORES_FUNCTIONS: function() { return 'a'.replace('a', function(){ return '' }).length !== 0; }, IS_TAGNAME_UPPERCASED: function() { return /[A-Z]/.test(document.documentElement.tagName); } // etc. sections, documentation... }; // make sure tests run only once Object.keys(tests)._each(function(test) { tests[test] = tests[test].wrap(function(proceed) { var result = proceed(); tests[test] = function() { return result }; return result; }); }); function test(name) { return tests[name](); } return { tests: tests, // could leave this out test: test }; })();