Skip to content

Commit

Permalink
Follow-up to 26c725 to work on more browsers.
Browse files Browse the repository at this point in the history
Windows Safari (eg) seems to apply the "uncheck existing radios when new radios
are created" even earlier than other browsers, so save values earlier.
  • Loading branch information
glasser committed Jan 3, 2013
1 parent fd13a9b commit a9a7179
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/spark/spark.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,18 @@ Spark.renderToRange = function (range, htmlFunc) {
notes.originalRange = landmarkRange;
});

// Once we render the new fragment, as soon as it is placed into the DOM (even
// temporarily), if any radio buttons in the new framgent are checked, any
// radio buttons with the same name in the entire document will be unchecked
// (since only one radio button of a given name can be checked at a time). So
// we save the current checked value of all radio buttons in an expando.
var radios = DomUtils.findAllClipped(
range.containerNode(), 'input[type=radio]',
range.firstNode(), range.lastNode());
_.each(radios, function (node) {
node._currentChecked = [!!node.checked];
});

var frag = renderer.materialize(htmlFunc);

DomUtils.wrapFragmentForContainer(frag, range.containerNode());
Expand Down Expand Up @@ -621,18 +633,6 @@ Spark.renderToRange = function (range, htmlFunc) {

pc.addRoot(Spark._globalPreserves, range, tempRange);

// computePreservations is going to insert 'tempRange' into the DOM
// temporarily. If any radio buttons in 'tempRange' are checked, this will
// instantly uncheck any radio buttons with the same name in 'range' (since
// only one radio button of a given name can be checked at a time). So we save
// the current checked value of all radio buttons in an expando.
var radios = DomUtils.findAllClipped(
range.containerNode(), 'input[type=radio]',
range.firstNode(), range.lastNode());
_.each(radios, function (node) {
node._currentChecked = [!!node.checked];
});

// compute preservations (must do this before destroying tempRange)
var preservations = pc.computePreservations(range, tempRange);

Expand Down

0 comments on commit a9a7179

Please sign in to comment.