Bug 141199

Summary: Range startContainer can't access parent 3 levels up in a contentEditable
Product: WebKit Reporter: Brandon Andrews <sirisian>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: ap
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Brandon Andrews 2015-02-03 09:45:59 PST
So startContainer in the range object behaves rather funny. It's like a pseudo element. === randomly fails when comparing to the DOM element got by getElementById, but .isEqualNode will always work. This might be correct to the spec I'm not sure, but one oddity in Webkit is that you can only access 2 parents up. If you do something like:

range.startContainer.parentNode.parentNode.parentNode it returns null. If you get the element startContainer is referencing and do element.parentNode.parentNode.parentNode it returns the correct DOM element. Very odd behavior.
Comment 1 Alexey Proskuryakov 2015-02-03 12:40:54 PST
Could you please attach a complete test case?
Comment 2 Brandon Andrews 2015-02-03 14:39:02 PST
I actually started trying to make a test case after submitting the bug assuming it would be easy to reproduce in a jsfiddle. I can't seem to reproduce it in a small test case even with most of the code.

It's not really a big issue. I'm sure someone else will be able to replicate it sometime in a smaller project. This project is so large it's hard to rip out everything to see what could be causing such odd behavior.

Sorry about that.