Skip to content

Commit

Permalink
Do not feed iterables to Map/Set constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaswilburn committed Sep 4, 2018
1 parent bc5e545 commit d5b1664
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ live.attr = function(el, attributeName, compute) {
// register that the handler changes the parent element
canReflect.assignSymbols(liveUpdateAttr, {
"can.getChangesDependencyRecord": function() {
var s = new Set();
s.add(el);
return {
valueDependencies: new Set( [ el ] )
valueDependencies: s
};
}
});
Expand Down
4 changes: 3 additions & 1 deletion lib/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ live.attrs = function(el, compute, scope, options) {
// register that the handler changes the parent element
canReflect.assignSymbols(liveAttrsUpdate, {
"can.getChangesDependencyRecord": function() {
var s = new Set();
s.add(el);
return {
valueDependencies: new Set( [ el ] )
valueDependencies: s
};
}
});
Expand Down
4 changes: 3 additions & 1 deletion lib/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ live.html = function(el, compute, parentNode, nodeListOrOptions) {
// register that the handler changes the parent element
canReflect.assignSymbols(liveHTMLUpdateHTML, {
"can.getChangesDependencyRecord": function() {
var s = new Set();
s.add(parentNode);
return {
valueDependencies: new Set( [ parentNode ] )
valueDependencies: s
};
}
});
Expand Down
4 changes: 3 additions & 1 deletion lib/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ live.text = function(el, compute, parentNode, nodeList) {
// register that the handler changes the parent element
canReflect.assignSymbols(liveTextUpdateTextNode, {
"can.getChangesDependencyRecord": function() {
var s = new Set();
s.add(parent);
return {
valueDependencies: new Set( [ parent ] )
valueDependencies: s
};
}
});
Expand Down
10 changes: 5 additions & 5 deletions test/html-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ test("html live binding handles objects with can.viewInsert symbol", 2, function
div.appendChild(placeholder);

var html = new Observation(function() {
return {
[canSymbol.for("can.viewInsert")]: function() {
assert.equal(arguments[0], options, "options were passed to symbol function");
return document.createTextNode("Replaced text");
}
var d = {};
d[canSymbol.for("can.viewInsert")] = function() {
assert.equal(arguments[0], options, "options were passed to symbol function");
return document.createTextNode("Replaced text");
};
return d;
});

live.html(placeholder, html, div, options);
Expand Down

0 comments on commit d5b1664

Please sign in to comment.