-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(serialization): restore explict class type #9009
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
Conversation
ShaMan123
left a comment
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.
Looks good
|
Build Stats
|
| QUnit.test('toString', function (assert) { | ||
| class Moo extends fabric.Object { | ||
| static type = 'moo' | ||
| static type = 'Moo' |
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.
NO IDEA why this class already had a static type and what was testing.
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.
This looks good.
This will also solve my Bug since we disconnected class name and type (but I still think my PRs are valid but they an wait now).
1 significant comment and another one for discussion
| const newClass = class extends ColorMatrix { | ||
| get type() { | ||
| return key; | ||
| } |
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.
should be removed, extending ColorMatrix is enough
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.
those had their own name before, will keep them.
I m not even sure is possible with the different defualts. Without their type class they would serialize to ColorMatrix and then to the next deserialize wouldn't work anymore
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.
It inherits the type getter so I don't see a need to hard code it since you assign the static type to it
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.
I want this removed because I think in the future it is a potential bug
Once we remove type getter this thing will become an artifact
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.
I m not even sure is possible with the different defualts
??
| * @param {String} type Type to check against | ||
| * @return {Boolean} | ||
| */ | ||
| isType(...types: string[]) { |
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.
should we deprecate this also??
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.
not part of this PR.
isType is not directly related to the incident. nor isType is wrong per se.
|
don't we need to update |
i think i did it? i m sure i did it. Let me double check. |
Your PRs are waiting there because trying to remove I was supposed to close them all and replace them with simple fixes, but every day we had something more important to do with fabric. |
|
Is because tabs designs sucks. At this point i need a test. |
|
@ShaMan123 we verified this unblock my teammates at work. |
How did tests pass then? |
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.
I understand now what happened with tests.
Good
because unminified code relies on class.name that still would work. |

Motivation
During the migration to "modern js" we thought that having a
typeproperty on an instance was kind of a duplicate because classes have costructor.name that is basically what type was.Dumbly enough we didn't think that minification would have changed variable names and so constructor.name.
This wasn't caught by tests since tests run on the non minified version of the code.
This PR aims at fixing:
#9006 and #9008 making #9007 obsolete.
It restores class type, as a static property that will take the place o constructor.name ( constructor.type ).
The compatibility getter for type on the instances is still there and will return the static type.
closes #9006
closes #9008
Description
Changes
Gist
In Action