Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(merge): ensure that jqlite->jqlite and DOM->DOM
Browse files Browse the repository at this point in the history
Previously we were wrapping DOM elements into jqlite objects when cloning
and vice versa.

Fixes #12286 (comment)
  • Loading branch information
petebacondarwin committed Nov 2, 2015
1 parent 4ff6c85 commit 75292a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ function baseExtend(dst, objs, deep) {
dst[key] = new Date(src.valueOf());
} else if (isRegExp(src)) {
dst[key] = new RegExp(src);
} else if (src.nodeName) {
dst[key] = src.cloneNode(true);
} else if (isElement(src)) {
dst[key] = src[0] ? jqLite(src).clone()[0] : jqLite(src).clone();
dst[key] = jqLite(src).clone();

This comment has been minimized.

Copy link
@gkalpak

gkalpak Nov 2, 2015

Member

Minor, but couldn't we just do src.clone() ? Or is there some hidden gotcha ?

This comment has been minimized.

Copy link
@petebacondarwin

petebacondarwin Nov 2, 2015

Author Contributor

Ahah! Yes, now that we know it is definitely not a DOM node, you are right

} else {
if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};
baseExtend(dst[key], [src], true);
Expand Down
2 changes: 2 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ describe('angular', function() {
expect(dst.jqObject).not.toBe(src.jqObject);

expect(isElement(dst.element)).toBeTruthy();
expect(jqLite(dst.element)).not.toBe(dst.element); // i.e it is a DOM element
expect(isElement(dst.jqObject)).toBeTruthy();
expect(jqLite(dst.jqObject)).toBe(dst.jqObject); // i.e it is a jqLite/jquery object
});
});

Expand Down

0 comments on commit 75292a6

Please sign in to comment.