Skip to content

Updating can-define/map documentation #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ec75ae4
updated example to es6 to prototype.assign.md
indifferentghost Aug 29, 2018
6b9371d
Updated example to ES6 syntax. Added link to codepen.
indifferentghost Aug 29, 2018
a70a63e
Updated examples, Added a use section hoping to elaborate what happen…
indifferentghost Aug 29, 2018
c84c78c
Updated to ES6 syntax. Made codepen-able. Added some documentation to…
indifferentghost Aug 29, 2018
50593d4
Updated syntax and and added codepen link.
indifferentghost Aug 29, 2018
497bf82
updated to ES6. It now links to codepen.
indifferentghost Aug 29, 2018
cc0dbc6
updateDeep is ES6. It now links to codepen.
indifferentghost Aug 29, 2018
925b9ba
Changed from single to double quote to match other examples.
indifferentghost Aug 29, 2018
09f24ef
added codepen example to the non deprecated use of set.
indifferentghost Aug 29, 2018
fc1794d
get has es6 codepenable examples.
indifferentghost Aug 29, 2018
0a69749
Syntax, ES6 and link to codepen added. Commented on issue #378 for ma…
indifferentghost Aug 29, 2018
a19484d
updated events.keys.md spacing
indifferentghost Aug 29, 2018
05ea58e
events.propertyName.md updated example.
indifferentghost Aug 29, 2018
c3dbf93
updated syntax and linked to codepen. Also threw them down to a use s…
indifferentghost Aug 29, 2018
b5e9b11
fixed spacing error in static.extend.md
indifferentghost Aug 29, 2018
50b319c
major updates to define-map.md documentation.
indifferentghost Aug 31, 2018
c92a6e4
added syntax highlighting and updated to es6 syntax for wildcard.
indifferentghost Aug 31, 2018
d37f13e
working es6 codepen-able example on static.seal.md
indifferentghost Aug 31, 2018
5fbd6f5
minor cleanup
justinbmeyer Sep 2, 2018
1f45e6f
some additional fixes
justinbmeyer Sep 3, 2018
f805d9a
use any now for accepting any type
justinbmeyer Sep 3, 2018
b71e7d6
Merge branch 'master' of https://github.com/canjs/can-define into 370…
indifferentghost Sep 4, 2018
0b20692
Merge branch '370-mapCodepen' of https://github.com/canjs/can-define …
indifferentghost Sep 4, 2018
0ea7a52
updated assign and assignDeep to more mirror their counterparts in li…
indifferentghost Sep 4, 2018
a4b8c5b
codepen updates across map.
indifferentghost Sep 4, 2018
879b73c
Updated and fixed spelling errors.
indifferentghost Sep 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions docs/deleteKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,45 @@

@signature `map.deleteKey(key)`

Deletes a key that was added to an instance, but not pre-defined by the type.
Deletes a key that was added to an instance, but not pre-defined by the type.

```js
import {DefineMap, Reflect} from "can";

const map = new DefineMap( {propA: "valueA"} );
console.log( map.propA ); //-> "valueA"

map.deleteKey("propA");
console.log( map.propA ); //-> undefined
```
@codepen

@param {String} key A string of the key being deleted.

@return {can-define/map/map} The map instance for chaining.

@body

## Use

If `deleteKey` is called on a pre-defined type it sets the value to `undefined`. This is to keep the setters and getters on all instances of that Type.

```js
import {DefineMap} from "can";
import {DefineMap, Reflect} from "can";

var Type = DefineMap.extend({seal: false},{
propA: "string"
});
const Type = DefineMap.extend(
{seal: false},
{
propA: "string"
}
);

var map = new Type({propA: "valueA"});
const map = new Type( {propA: "valueA"} );
map.set("propB","valueB");
map.deleteKey("propB"); // this works.
map.deleteKey("propA"); // this does not work.
map.deleteKey("propB"); // This works.
map.deleteKey("propA"); // This doesn't delete the key, but does set the key to undefined.

console.log( Reflect.getOwnKeys(map) ); //-> ["propA"]
console.log( map.propA ); //-> undefined
```
@codepen
Loading