Using 'type' as a custom attribute conflicts with Konva internal node type and causes unexpected behavior #2011
Closed
JhonnyCarvajalFE
started this conversation in
General
Replies: 1 comment
-
|
This is the code of getAttr method: getAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(
attr: K
): K extends keyof AttrConfig ? AttrConfig[K] : any {
const method = 'get' + Util._capitalize(attr as string);
if (Util._isFunction((this as any)[method])) {
return (this as any)[method]();
}
// otherwise get directly
return this.attrs[attr];
}As you can see, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was creating shapes with a custom
typeattribute and accessing it usingnode.getAttr('type'). The documentation mentions agetType()method that returns the node’s internal type (e.g., Shape, Group, or Stage), butgetAttr('type')appears to return the same value asgetType()rather than the custom attribute, which caused unexpected behavior. So I guesstypeis a lib keyword you cant use as a custom attribute, right?Beta Was this translation helpful? Give feedback.
All reactions