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

Why I can't name my event as 'constructor'? #3999

Closed
unclechu opened this issue Mar 29, 2016 · 9 comments
Closed

Why I can't name my event as 'constructor'? #3999

unclechu opened this issue Mar 29, 2016 · 9 comments

Comments

@unclechu
Copy link
Contributor

_.extend({}, Backbone.Events).on('constructor', function () {});

Throws exception:

TypeError: handlers.push is not a function

Is it a bug?
I can reproduce it in developer console on backbonejs.org site.

@Florian-R
Copy link

FWIW, this is not the same bug but somehow related to #1495, which was closed as wontfix.

@megawac
Copy link
Collaborator

megawac commented Mar 29, 2016

This can be fixed by ensuring the handler is an array.

var handlers = _.isArray(events[name]) ? events[name] : (events[name] = []);

Thoughts @jridgewell @akre54

@akre54
Copy link
Collaborator

akre54 commented Mar 29, 2016

Eh. I think our short circuit pattern is fairly common in JS. The advice around edge cases in #1495 applies here too.

@jridgewell
Copy link
Collaborator

Can we just drop IE8 now? Hell, even IE8 can do a prototype-less object with black magic.

@akre54
Copy link
Collaborator

akre54 commented Mar 29, 2016

What you got in mind? Object.create everywhere?

@mr47
Copy link

mr47 commented Mar 29, 2016

@jridgewell my god.

@megawac
Copy link
Collaborator

megawac commented Mar 29, 2016

Hell, even IE8 can do a prototype-less object with black magic.

You're not kidding, I'm pretty sure that ActiveXObject is literally a gate to hell

@akre54
Copy link
Collaborator

akre54 commented Mar 29, 2016

That's insane

@jridgewell
Copy link
Collaborator

That's insane

Cliched genius and madness quote. 😉

jrmils89 added a commit to jrmils89/backbone that referenced this issue Apr 10, 2016
This changes all the places where object literals were being used to use
prototypless-objects. This addresses the issue raised in
jashkenas#3999
wuworkshop added a commit to jrmils89/backbone that referenced this issue Apr 10, 2016
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

7 participants