Closed Bug 1622032 Opened 4 years ago Closed 4 years ago

Element.replaceChild should give helpful error if you use the (old, new) argument order by detecting if `old` has no parent and `new` *is* in the correct parent

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: Gijs, Assigned: bzbarsky)

Details

Attachments

(2 files)

This keeps tripping everyone up, because really replaceChild(old, new) would make more sense. It would be nice to have a "nice" warning that tells developers they're messing up the order. Right now we just say "Node not found" (because the "old" node is the new node, and it isn't a child of the parent on which replaceChild is called), which is... unhelpful.

Previously: bug 1217 (not a typo)

"Old" is our current exception message. "New" is the new one with the patch that's coming up. "Chrome" is Chrome's message.

Attachment #9132984 - Attachment mime type: text/plain → text/html
Attachment #9132984 - Attachment filename: file_1622032.txt → file_1622032.html

In particular, improve the error message for replaceChild when the two arguments get switched.

Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/34c321955d42
Improve some error messages in nsINode. r=nika
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: