Skip to content

Commit

Permalink
Merge pull request #153 from canjs/legacy-attr-compat
Browse files Browse the repository at this point in the history
Support legacy .attr() and serialize behavior
  • Loading branch information
marshallswain authored Aug 23, 2021
2 parents e112828 + 06c8c03 commit 27287a3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions map-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ var mapHelpers = {
}

serializeMap[how][cid] = where;
// Go through each property.
map.forEach(function (val, name) {

function handleAttribute (val, name) {
// If the value is an `object`, and has an `attr` or `serialize` function.
var result,
isObservable = canReflect.isObservableLike(val),
Expand All @@ -123,7 +123,17 @@ var mapHelpers = {
if(result !== undefined){
where[name] = result;
}
});
}
// Go through each property.
map.forEach(handleAttribute);
// For legacy behavior, includes attrs whose can.define spec includes `serialize: false`
if (map._legacyAttrBehavior && how === "attr" && map.define) {
Object.keys(map.define).forEach(function (name) {
if (map.define[name].serialize === false) {
handleAttribute(map.attr(name), name)
}
})
}

if(firstSerialize) {
serializeMap = null;
Expand Down

0 comments on commit 27287a3

Please sign in to comment.