Closed Bug 1141498 Opened 10 years ago Closed 10 years ago

Make testcommon.js's addDiv() more portable, and more flexible

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: jwatt, Assigned: jwatt)

Details

Attachments

(2 files)

No description provided.
From bug 1073379 comment 22: According to MDN... https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#Browser_compatibility ...remove() isn't supported everywhere -- it's supported not in IE, at least. Given that this is a testharness.js test & hence can in theory be run w/ other browsers, maybe better to avoid using remove(). (and use div.parentNode.removeChild(div) instead)
Per the "Obviously, feel free to wrap or extend it to add the extra class / ID setting behaviour" comment in bug 1072037 comment 11.
Attachment #8575256 - Flags: review?(dholbert)
Attachment #8575255 - Flags: review?(dholbert) → review+
Comment on attachment 8575256 [details] [diff] [review] part 2 - Enable calls to DOM animation test's testcommon.js's addDiv() to set attributes >+++ b/dom/animation/test/testcommon.js >-function addDiv(t) { >+function addDiv(t, attrs) { > var div = document.createElement('div'); >+ if (attrs) { >+ for (var attr in attrs) { >+ div.setAttribute(attr, attrs[attr]); >+ } >+ } nit: maybe rename "attr" to "attrName"? For me at least, that'd make the setAttribute call easier to skim & make it easier to keep track of what the various values involved are. r=me regardless
Attachment #8575256 - Flags: review?(dholbert) → review+
Sure, sounds good.
Part 1 caused the test test_element-get-animation-players.html to fail because calling element.remove() is a no-op when the element has no parent node, but of course if element.parentNode is null then evaluating element.parentNode.removeChild(element) causes a JavaScript error. So despite how the patch looked, the old and new code are not strictly equivalent! :/
Flags: needinfo?(jwatt)
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: