Skip to content
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

.set is confusing in how it work on plain DefineMaps versus extended DefineMaps #401

Open
mjstahl opened this issue Oct 12, 2018 · 0 comments

Comments

@mjstahl
Copy link
Contributor

mjstahl commented Oct 12, 2018

The Problem

The documentation for .set located at https://canjs.com/doc/can-define/map/map.prototype.set.html states:

Assigns value to a property on this map instance called propName. This will define the property if it hasn't already been predefined.

This (defining a property, not previously defined) works for plain (not extended) DefineMaps, but fails to work on the example below.

const MyMap = DefineMap.extend({});
const mapB = new MyMap({});
mapB.set("propA", "value");

The Solution

The documentation for .set should state (very plainly) that you cannot extend an extended DefineMap and the error it would throw if you try.

As a bonus it might be worth explain /why/ an extended DefineMap is sealed where as a plain DefineMap is not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants