Skip to content

Commit 8538587

Browse files
authored
Merge pull request #142 from canjs/assign-docs
Fixes the update/updateDeep docs
2 parents 33945b8 + 6e45a37 commit 8538587

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

reflections/shape/shape.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -912,15 +912,16 @@ shapeReflections = {
912912
*
913913
* @signature `.update(target, source)`
914914
*
915-
* Updates the values (and properties if map-like) of `target` to match the values of `source`. This does
915+
* Updates the values (and properties if map-like) of `target` to match the values of `source`.
916+
* Properties of `target` that are not on `source` will be removed. This does
916917
* not recursively update. For that, use [can-reflect.updateDeep].
917918
*
918919
* For map-like objects, every enumerable property on `target` is copied:
919920
*
920921
* ```js
921922
* var target = {name: {first: "Justin"}, age: 34};
922923
* var source = {name: {last: "Meyer"}};
923-
* var restult = canReflect.assignDeep(target, source);
924+
* var result = canReflect.update(target, source);
924925
* target //-> {name: {last: "Meyer"}}
925926
* ```
926927
*
@@ -929,7 +930,7 @@ shapeReflections = {
929930
* ```js
930931
* var target = ["a","b","c"];
931932
* var source = ["A","B"];
932-
* canReflect.assign(target, source);
933+
* canReflect.update(target, source);
933934
* target //-> ["A","B"]
934935
* ```
935936
*
@@ -988,17 +989,18 @@ shapeReflections = {
988989
* @signature `.updateDeep(target, source)`
989990
*
990991
* Updates the values (and properties if map-like) of `target` to match the values of `source`.
992+
* Removes properties from `target` that are not on `source`.
991993
*
992994
* For map-like objects, every enumerable property on `target` is copied:
993995
*
994996
* ```js
995997
* var target = {name: {first: "Justin"}, age: 34};
996998
* var source = {name: {last: "Meyer"}};
997-
* var restult = canReflect.assignDeep(target, source);
999+
* var result = canReflect.updateDeep(target, source);
9981000
* target //-> {name: {last: "Meyer"}}
9991001
* ```
10001002
*
1001-
* An object can control the behavior of `assignDeep` using the [can-symbol/symbols/updateDeep] symbol.
1003+
* An object can control the behavior of `updateDeep` using the [can-symbol/symbols/updateDeep] symbol.
10021004
*
10031005
* For list-like objects, a diff and patch strategy is used. This attempts to limit the number of changes.
10041006
*

0 commit comments

Comments
 (0)