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

Filter out prototype properties #187

Merged
merged 1 commit into from
Aug 19, 2013
Merged

Filter out prototype properties #187

merged 1 commit into from
Aug 19, 2013

Conversation

johnste
Copy link
Contributor

@johnste johnste commented Jul 2, 2013

Make sure to filter out properties from the prototype. Currently pixi.js doesn't work with ember.js due to this.


listeners[ event.type ][ listener ]( event );
for ( var listener in listeners[ event.type ] ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't seen this code yet, but since you brought it to attention, listeners[ event.type ] is an array. So it's safer just to...

for(var i = 0, l = listeners[ event.type ].length; i < l; i++)

There's a few other optimizations I may do in this file, in another pull request. Backbone.Events is a great model to follow for performance, across most, if not all modern platforms. I recently ported it to a proprietary engine pretty easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right of course. I'll update the pull request.

@englercj
Copy link
Member

👍 Sorry it took so long to get around to this, it looks good. I appreciate you following the code style in this file (even though it looks ridiculous).

Although the if ( typeof listeners[ event.type ] !== 'function' ) { check is incorrect, and unnecessary if you are using a proper for loop. If .length is undefined then the loop condition will fail, and filter prototype properties implicitly.

englercj added a commit that referenced this pull request Aug 19, 2013
Use proper array iteration
@englercj englercj merged commit 3ea4056 into pixijs:dev Aug 19, 2013
englercj added a commit that referenced this pull request Aug 19, 2013
@lock
Copy link

lock bot commented Feb 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 26, 2019
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

3 participants