#3283 closed Bug (invalid)
'CKEDITOR.dom.node.getPreviousSourceNode/getNextSourceNode' bug
Reported by: | Garry Yao | Owned by: | Garry Yao |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 3.0 |
Component: | General | Version: | |
Keywords: | Confirmed Review- | Cc: |
Description
I've detected the 'previous source node' is incorrect with the attache d TC.
Attachments (5)
Change History (15)
Changed 15 years ago by
Attachment: | 3283.patch added |
---|
comment:1 Changed 15 years ago by
Keywords: | Confirmed Review? added |
---|---|
Owner: | set to Garry Yao |
Status: | new → assigned |
comment:2 follow-up: 4 Changed 15 years ago by
comment:3 follow-up: 6 Changed 15 years ago by
Keywords: | Review- added; Review? removed |
---|
It isn't possible to walk backwards in DFS order without using lastChild.
e.g. the following script, when executed within the replacebyclass.html sample, will never give you the correct backwards walk no matter whether you feed true or false to getPreviousSourceNode():
f = frames[0]; c = l = new CKEDITOR.dom.element(f.document.links[0]). getNextSourceNode(); // The "FCKeditor" text node while(c = c.getPreviousSourceNode(true)) console.log(c.getOuterHtml ? c.getOuterHtml() : c.getText());
Changed 15 years ago by
Attachment: | 3283_2.patch added |
---|
comment:4 Changed 15 years ago by
Replying to martinkou:
#2980 may be affected by this change since it depends on the wrong behavior of getPreviousNode() - actually it tries to get the right behavior by feeding it a true argument.
This function has a lot of confusing which is error prone, and I've spotted some places which relay on the wrong behavior of this function, let's figure out and fix them after we have a common cognition with the 'correct' behavior.
comment:5 Changed 15 years ago by
Keywords: | Review? added; Review- removed |
---|
I've come with a new patch which simplified the implementation by utilize 'domWalker' and updated the TCs. Please first give a review to those TCs and then the patch.
comment:6 Changed 15 years ago by
Replying to martinkou: I've tested with the new patch's passing your TC Martin, please reconfirm.
comment:7 Changed 15 years ago by
Summary: | 'CKEDITOR.dom.node.getPreviousSourceNode' bug → 'CKEDITOR.dom.node.getPreviousSourceNode/getNextSourceNode' bug |
---|
Update the description since the CKEDITOR.dom.node.getNextSourceNode is not right also, we're going to fix it here.
Changed 15 years ago by
Attachment: | 3283_3.patch added |
---|
Changed 15 years ago by
Attachment: | test-getPreviousSourceNode-getNextSourceNode.patch added |
---|
Changed 15 years ago by
Attachment: | test-getPreviousSourceNode-getNextSourceNode_2.patch added |
---|
comment:9 Changed 15 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
The original TCs are incorrect. Let me make some clarifications to justify it.
Suppose we have the following structure:
<p><b>A</b>B</p><div>C</div>
These two functions must return the first "touched node", from LTR or RTL, depending on the function.
So getNextSourceNode is supposed to return us the nodes in this order:
<p> -> <b> -> A -> B -> <div> -> C
getPreviousSourceNode instead is not supposed to give the exact opposite of it, but to apply the same logic, reading the code from right to left:
<div> -> C -> <p> -> B -> <b> -> A
In this case, the "touch point" of the elements are their "end boundary".
It's also quite easy to understand the why of it. In the original TCs conception, getPreviousSourceNode should return <p> by both <b> and <div>, which is wrong as we need to different results for each one of them, considering their different locations.
I've attached the correct TCs for it.
comment:10 Changed 15 years ago by
Keywords: | Review- added; Review? removed |
---|
Now I understood the semantic of 'getPreviousSourceNode' function throughly Fred, I'll update the original TCs.
#2980 may be affected by this change since it depends on the wrong behavior of getPreviousNode() - actually it tries to get the right behavior by feeding it a true argument.