-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
fix(): Avoid errors on restoring custom properties that pass the lazy detection of shadow,gradient,pattern and clipPath #10017
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Ok i see your point, but we can't return value on a catch, it will make unparsed pattern returned as is with errors later. |
Maybe we can change:
to
and then we can use if that will make custom properties safe. And you can do the same for patterns? |
done. |
Adding a test and merging |
src/util/misc/objectEnlive.ts
Outdated
'stroke', | ||
'path', | ||
'backgroundImage', | ||
'overlayImage', |
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.
we forgot 3 cases.
I m having a second thought we did it the wrong fix here. |
@zhe-he look at how i changed it, and let me know. |
@asturur |
The fix we made with the properties was making impossible extend a class with a restorable property. because if you added a custom property like 'mask' with a restorable object, then the allow list we built would have blocked you |
Using hasClass is not very reliable either. I might have a custom attribute whose type value happens to exist in Fabric's types, such as Rect, Textbox, Path, etc. Can we first check if the key is a Fabric property, and then check if the value exists in the classRegistry? |
That would be bad design on implementer side. Why shoud you block someone from adding a custom property that is correctly enlivable? |
Okay, if this is reasonable, then it is indeed unnecessary to over-design. I agree with you that allowing users to customize properties of built-in objects is a good idea. |
When importing, each property of the object will be iterated over. If a property has type and source, additional logic will be executed. If the user has custom-exported additional properties, and the property is an object with type or source keywords, the user needs to output it as is.