Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Bug: attributes inherited from Object.prototype #1495

paulmillr opened this Issue · 3 comments

3 participants

john = new Backbone.Model()

building1 = new Backbone.Model()
building1.set {constructor: john}
building1.has 'constructor'  # => true

building2 = new Backbone.Model()
building2.has 'constructor'  # => true. WTF?

Whole bunch of issues here, model.has("hasOwnProperty") == true as well. Any ideas on a patch other than using hasOwnProperty ?


I'm using Object.create(null) in cases like that, we can check for its support and use this if it's supported. One-line patch:

this.attributes = typeof Object.create === 'function' ? Object.create(null) : {};

A patch that will support old ie is much more sophisticated. _.has(this.attributes, attr) should be placed everywhere etc.


Yep -- not so much a bug as a known limitation. Take care with your attribute keys. Making your proposed patch would cause working code in webkit / firefox to error in internet explorer, a situation we'd like to avoid as much as possible.

@jashkenas jashkenas closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.