Closed
Bug 338954
Opened 19 years ago
Closed 19 years ago
Make .innerHTML to work without DOM Ranges
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: smaug, Assigned: smaug)
Details
Attachments
(2 files, 2 obsolete files)
|
2.03 KB,
text/html
|
Details | |
|
29.87 KB,
patch
|
jst
:
superreview+
|
Details | Diff | Splinter Review |
Currently .innerHTML getter and setter use DOM ranges. But if
ranges are fixed to work only when nodes are in document/document fragment/attr .innerHTML stops working for elements which aren't in
the document.
| Assignee | ||
Comment 1•19 years ago
|
||
| Assignee | ||
Comment 2•19 years ago
|
||
Attachment #223015 -
Attachment is obsolete: true
| Assignee | ||
Comment 3•19 years ago
|
||
The biggest change here is to move the implementation of
CreateContextualFragment from nsRange to nsContentUtils.
The scariest change is to use docEncoder->SetContainerNode
(not ->SetRange())
Attachment #223023 -
Flags: review?(bugmail)
| Assignee | ||
Comment 4•19 years ago
|
||
The "scary" part is that dom gets serialized in a simpler way.
No need to handle start/endContainer of the range because they are
anyway always the same node (which is why there is no need to use range
at all).
I tested the patch also with some test cases found in bugzilla and
couldn't see any regressions.
Status: NEW → ASSIGNED
Comment on attachment 223023 [details] [diff] [review]
proposed patch
>+nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
...
>+ while (parent && (parent != domDocument) && NS_SUCCEEDED(rv)) {
Please |break| in all places where rv could become an error and remove the last condition here. The rv variable is really volitile so it should be checked asap to avoid future code from clamping all over it.
>+ PRUint16 nodeType;
>+ parent->GetNodeType(&nodeType);
>+ if (nsIDOMNode::ELEMENT_NODE == nodeType) {
>+ nsAutoString tagName, uriStr;
>+ parent->GetNodeName(tagName);
>+
>+ // see if we need to add xmlns declarations
>+ nsCOMPtr<nsIContent> content = do_QueryInterface(parent, &rv);
>+ if (NS_FAILED(rv)) {
>+ break;
>+ }
Don't use nsresults with QI, instead just nullcheck the return.
>Index: content/base/src/nsDocumentEncoder.cpp
> nsresult SerializeToStringRecursive(nsIDOMNode* aNode,
>- nsAString& aStr);
>+ nsAString& aStr,
>+ PRBool aNodeIsContainer = PR_FALSE);
Something like |aDontSerializeRoot| or |aJustSerializeChildren| might be more descriptive, up to you.
Don't use default parameters though, please just change all call sites. Default params just make further signature changes harder.
With that, r=me
Attachment #223023 -
Flags: review?(bugmail) → review+
| Assignee | ||
Comment 6•19 years ago
|
||
Attachment #223023 -
Attachment is obsolete: true
Attachment #223895 -
Flags: superreview?(jst)
Comment 7•19 years ago
|
||
Comment on attachment 223895 [details] [diff] [review]
v2
sr=jst
Attachment #223895 -
Flags: superreview?(jst) → superreview+
| Assignee | ||
Updated•19 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•