Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add workaround for broken splitText() in IE9 #11

Open
timdown opened this Issue · 2 comments

2 participants

@timdown

Here's a Stack Overflow question illustrating the problem:

http://stackoverflow.com/questions/7378186/ie9-childnodes-not-updated-after-splittext

I cam across this problem independently. Here's my workaround:

function insertAfter(node, precedingNode) {
var nextNode = precedingNode.nextSibling, parent = precedingNode.parentNode;
if (nextNode) {
parent.insertBefore(node, nextNode);
} else {
parent.appendChild(node);
}
return node;
}

// Note that we cannot use splitText() because it is bugridden in IE 9.
function splitDataNode(node, index) {
var newNode = node.cloneNode(false);
newNode.deleteData(0, index);
node.deleteData(index, node.length - index);
insertAfter(newNode, node);
return newNode;
}

@Raynos
Owner

@timdown If you want to be fixed at some kind of decent time period then adding a unit test that breaks will speed me up ;)

@timdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.