Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Throw an exception when adding a non-object pane item #7633

Merged
merged 1 commit into from Jul 1, 2015

Conversation

nathansobo
Copy link
Contributor

Closes #5978

We end up attempting to retrieve a view for pane items from a WeakMap, which can only use objects as keys. Throwing an exception earlier helps to clarify to package authors that this won't work.

@@ -336,6 +336,8 @@ class Pane extends Model
#
# Returns the added item.
addItem: (item, index=@getActiveItemIndex() + 1) ->
throw new Error("Added a null item") unless item? and typeof item is 'object'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message seems a bit confusing since it isn't always a null item, it also throws for numbers and strings right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Oversight. I expanded to non-objects and forgot to update the message.

@nathansobo nathansobo force-pushed the ns-pane-items-must-be-objects branch from dc04e79 to 8348b2c Compare July 1, 2015 18:29
nathansobo pushed a commit that referenced this pull request Jul 1, 2015
Throw an exception when adding a non-object pane item
@nathansobo nathansobo merged commit 550efc8 into master Jul 1, 2015
@nathansobo nathansobo deleted the ns-pane-items-must-be-objects branch July 1, 2015 19:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants