-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
src/animation: Convert to es6 classes #20014
Conversation
e707daf
to
3afe5c5
Compare
e6f0d31
to
1d9b33c
Compare
1d9b33c
to
73d6e25
Compare
@ianpurvis Do you mind resolving the merge conflicts? |
@Mugen87 Will do! |
73d6e25
to
070b340
Compare
Fyi, I discarded c4872f5 in light of #21293 |
@@ -118,14 +42,14 @@ Object.assign( AnimationClip, { | |||
|
|||
} | |||
|
|||
const clip = new AnimationClip( json.name, json.duration, tracks, json.blendMode ); | |||
const clip = new this( json.name, json.duration, tracks, json.blendMode ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah! I didn't know you could do new this()
🤓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I see you do new this.constructor
a bit further down the file. What's the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! If you are constructing from a static method you can use this()
, otherwise you have to use this.constructor()
class Foo {
constructor(attributes) {
Object.assign(this, attributes);
}
static create(attributes) {
return new this(attributes);
}
clone() {
return new this.constructor(this) ;
}
}
class Bar extends Foo { }
const objects = [
new Foo({ name: 'foo1' }),
Foo.create({ name: 'foo2' }),
new Foo({ name: 'foo3' }).clone(),
new Bar({ name: 'bar1' }),
Bar.create({ name: 'bar2' }),
new Bar({ name: 'bar3' }).clone(),
]
for (const obj of objects) {
console.log(obj);
}
Outputs -->
Foo { name: 'foo1' }
Foo { name: 'foo2' }
Foo { name: 'foo3' }
Bar { name: 'bar1' }
Bar { name: 'bar2' }
Bar { name: 'bar3' }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang. You know your stuff! 🙏
Apart from the |
Caught and fixed an issue in 9c437fd 👍 |
Thanks! |
Supports #19986