Created
May 22, 2014 15:59
-
-
Save usmonster/ffd0b58abca7c3999b38 to your computer and use it in GitHub Desktop.
tests for Element.prototype.textContent shim INCOMPLETE DRAFT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | |
<script type="text/javascript"> | |
var log; | |
if ('console' in window && 'log' in window.console) { | |
log = function (x){ console.log(x); }; | |
} else { | |
log = function(){}; | |
} | |
function test(when) { | |
var div = document.createElement('div'); | |
div.innerHTML = '<span>tick!</span>'; | |
var span = div.childNodes[0]; | |
try { | |
log('span ihtml: '+ span.innerHTML); | |
log('span itext: '+ span.innerText); | |
log('span tcontent: '+ span.textContent); | |
log('span owner doc: '+ span.ownerDocument); | |
log('changing DIV tcontent...'); | |
div.textContent = 'TICK!'; | |
log('span ihtml: '+ span.innerHTML); | |
log('span itext: '+ span.innerText); | |
log('span tcontent: '+ span.textContent); | |
log('span owner doc: '+ span.ownerDocument); | |
log('Now for the text node inside the span...'); | |
var text = span.childNodes[0]; | |
log('text tcontent: '+ text.textContent); | |
log('text owner doc: '+ text.ownerDocument); | |
log('changing TEXT tcontent...'); | |
text.textContent = 'TICK??!?'; | |
log('text tcontent: '+ text.textContent); | |
log('text owner doc: '+ text.ownerDocument); | |
log('span ihtml: '+ span.innerHTML); | |
log('span itext: '+ span.innerText); | |
log('span tcontent: '+ span.textContent); | |
log('span owner doc: '+ span.ownerDocument); | |
log('changing SPAN tcontent...'); | |
span.textContent = 'boom?'; | |
log('text tcontent: '+ text.textContent); | |
log('text owner doc: '+ text.ownerDocument); | |
log('span ihtml: '+ span.innerHTML); | |
log('span itext: '+ span.innerText); | |
log('span tcontent: '+ span.textContent); | |
log('span owner doc: '+ span.ownerDocument); | |
log('changing SPAN itext...'); | |
span.innerText = 'BOOM???'; | |
log('text tcontent: '+ text.textContent); | |
log('text owner doc: '+ text.ownerDocument); | |
log('span ihtml: '+ span.innerHTML); | |
log('span itext: '+ span.innerText); | |
log('span tcontent: '+ span.textContent); | |
log('span owner doc: '+ span.ownerDocument); | |
alert(when+': worked!'); | |
} catch (ex) { | |
alert(when+': NOPENOPENOPE'); | |
} | |
} | |
</script> | |
<script type="text/javascript">test('before');</script> | |
<!--[if lt IE 9]> | |
<script type="text/javascript" src="element-properties.js"></script> | |
<script type="text/javascript">test('after');</script> | |
<![endif]--> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment