Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DomUtils.htmlToFragment with SELECTs. Add helpers.
When a <SELECT> was rendered on IE9 (or older) via DomUtils.htmlToFragment, the hack we used somehow failed to properly set some attributes; they would show up in innerHTML but not affect property values. eg, SELECTED would show up in an OPTION's innerHTML but option.selected would not be set (nor would the parent SELECT's value or selectedIndex). Fix this by replacing a mergeAttributes call with an explicit attribute copying loop. Also, add the helpers setElementValue and getElementValue to DomUtils, which are used both in the test of this fix and will be used in a future change. Fixes #496.
- Loading branch information
Showing
2 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
// TESTS GO HERE | ||
Tinytest.add("domutils - setElementValue", function (test) { | ||
var div = OnscreenDiv(); | ||
div.node().appendChild(DomUtils.htmlToFragment( | ||
("<select><option>Foo</option><option value='Bar'>Baz</option>" + | ||
"<option selected value='Quux'>Quux</option></select>"))); | ||
|
||
var select = DomUtils.find(div.node(), 'select'); | ||
test.equal(DomUtils.getElementValue(select), "Quux"); | ||
_.each(["Foo", "Bar", "Quux"], function (value) { | ||
DomUtils.setElementValue(select, value); | ||
test.equal(DomUtils.getElementValue(select), value); | ||
}); | ||
}); |