diff --git a/tests/functional/test_misc_ie90.py b/tests/functional/test_misc_ie90.py index 22727f568d..469bfc53e9 100644 --- a/tests/functional/test_misc_ie90.py +++ b/tests/functional/test_misc_ie90.py @@ -1402,3 +1402,12 @@ def test_testIEVisibility(self, caplog): "[Window] Alert Text: document.msVisibilityState: visible"] self.do_perform_test(caplog, sample, expected) + + def test_testSplitText(self, caplog): + sample = os.path.join(self.misc_path, "testSplitText.html") + expected = ["p.childNodes.length before splitText: 1", + "foobar value after splitText: foo", + "bar value: bar", + "p.childNodes.length after splitText: 2"] + + self.do_perform_test(caplog, sample, expected) diff --git a/thug/DOM/W3C/Core/Text.py b/thug/DOM/W3C/Core/Text.py index ba789bf9d2..06da1d1c86 100644 --- a/thug/DOM/W3C/Core/Text.py +++ b/thug/DOM/W3C/Core/Text.py @@ -10,7 +10,13 @@ def __init__(self, doc, tag): CharacterData.__init__(self, doc, tag) def splitText(self, offset): - raise DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR) + newNode = self.doc.createTextNode(self.data[offset:]) + self.data = self.data[:offset] + + if self.parentNode: + self.parentNode.insertBefore(newNode, self.nextSibling) + + return newNode def getNodeValue(self): return str(self.data)