If you want to import these classes to do things like
node.fill instanceof LinearGradient
you have to drop the “Fill” suffix. The class creation functions are indeed called
LinearGradientFill
RadialGradientFill
which is confusing. Perhaps the names exported from scenegraph should be fixed? Or augmented (so it won’t break existing code)?
I console-log’d the results of webpack loading the scenegraph module, and here’s the relevant portion:
RepeatGrid: { [Function: RepeatGrid] super_: [Function: SceneNode] },
SymbolInstance: { [Function: SymbolInstance] super_: [Function: SceneNode] },
LinkedGraphic: { [Function: LinkedGraphic] super_: [Function: SceneNode] },
Matrix: { [Function: Matrix] newFromString: [Function] },
Color: { [Function: Color] deserializeAGC: [Function] },
LinearGradient: [Function: LinearGradientFill],
RadialGradient: [Function: RadialGradientFill],
ImageFill: { [Function: ImageFill] SCALE_COVER: 'cover', SCALE_STRETCH: 'normal' },
Blur: { [Function: Blur] deserializeAGC: [Function] },
Shadow: { [Function: Shadow] deserializeAGC: [Function], deserialize: [Function] },
in which case you can see that only these two module exports don’t match the function (class) names.
gdreyv
July 10, 2019, 12:30pm
2
Just in case:
opened 12:20AM - 02 Jul 19 UTC
closed 10:16AM - 01 Jan 20 UTC
bug
duplicate
Please adjust names of these classes as it doesn't work now.
https://forums.ado… bexdplatform.com/t/what-namespace-is-lineargradientfill/942/2
https://github.com/AdobeXD/plugin-docs/issues/179
@peterflynn , is this something we’re planning on updating in the references?
opened 09:31AM - 25 Feb 19 UTC
# Submit an issue
## Topic
This is an issue regarding:
- [x] Core docs.…
- [x] The tutorials contained within this repo.
- [x] The samples contained within this repo.
## Versions
- [ ] Supported XD version(s):
## Description of the issue
Documented as `LinearGradientFill`.
## Proposed solution or attempted solutions that failed
Should be `LinearGradient`.
## Reported by:
@pklaschka and XD forums member `@prime`
Sorry if I missed something.
Thanks, good to know it’s been spotted before.
gdreyv
July 10, 2019, 2:47pm
4
I just want to draw a bit more attention as it’s old problem with breaking fix. Now there are 2 ways to define what fill is used. It’s either:
more obvious: usage of instanceof with not documented (fill instanceof LineatGradient
) class name or…
more tricky: check constructor name and compare with documented class name (consturctor.name === 'LineatGradientFill'
).
Any fix will break one of the way used in the plugins.
They could also add the correct aliases for the same names in the module export. Nothing breaks, and then instance of LinearGradientFill
, etc., starts working.
2 Likes
cpryland:
They could also add the correct aliases for the same names in the module export. Nothing breaks, and then instance of LinearGradientFill
, etc., starts working.
Agreed, although I wouldn’t like that as a long-term solution. Maybe add an alias for a few versions, mark it as deprecated to give us time to adjust plugins and then remove the alias, leaving the “real” thing (whatever that is) there.
1 Like
gdreyv
July 10, 2019, 3:02pm
7
Are there any notifications for developers to let them know that plugin will stop working in couple versions?
Agreed this is a confusing point. @peterflynn is this something we can fix soon?