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

Add back support for named behaviors #22423

Merged
merged 2 commits into from May 15, 2018
Merged

Add back support for named behaviors #22423

merged 2 commits into from May 15, 2018

Conversation

balderdash
Copy link
Contributor

@balderdash balderdash commented May 15, 2018

Behavior equality broke for old behaviors, because they were often written to create a new function every time you try to add or remove them, e.g.:

function float(sprite) {
  var behavior = function(sprite) {
    sprite.moveUp();
  }
  behavior.name = 'float';
  return behavior;
}

It used to work because equality was just based on the name, but now we can compare functions directly. Because equality is broken, you can add the same behavior multiple times and you can never remove a behavior.

(Some old behaviors still work because they declared the function once and just returned it over and over, but most weren't written that way).

This PR brings back name-based comparisons.

I tried writing tests, but the name property on functions is readonly outside of JSInterpreter, so I just had to verify manually. That behavior broke a couple tests as well.

@balderdash balderdash requested a review from Hamms May 15, 2018 18:21
Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

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

LGTM!

@balderdash balderdash merged commit 65d9246 into staging May 15, 2018
@balderdash balderdash deleted the behavior-fix branch May 18, 2018 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants