Repository navigation
Add default setter values when undefined - #954
Conversation
|
nice! this looks good - want to add more or can we mark it ready for review? |
|
Thanks for the feedback. I think it would also be nice to do this for the |
wouterlucas
left a comment
There was a problem hiding this comment.
LGTM @jfboeve can you do a final scan and merge it if you think its good?
| private fontHandler: FontHandler; | ||
|
|
||
| private _layoutGenerated = false; | ||
| protected _layoutGenerated = false; |
There was a problem hiding this comment.
My bad, I should have reverted that after testing, currently we have a patch on our client repo to change that property to protected because we are extending the CoreTextNode class and we have custom setters where we are doing: this._layoutGenerated = false;.
This an unrelated change so I will revert that, well spotted
On our client app we are reusing some text elements. To avoid always doing
xProperty = config.x || defaulttXit would be simpler to allowundefinedon the setter functions.Some properties already seem to assume the value can be
undefined, despite the type being mandatory, like theletterSpacingor thetext setterproperty. This only passes because the eslint rule@typescript-eslint/no-unnecessary-conditionis turned off.Summary
CoreTextNodenow use the same defaults ascreateTextNodewhen the value isundefined.0and''are kept.createTextNodestill uses||, so a falsy value passed at creation is still replaced.textstill turnsnullinto'', and non-strings such as0andfalseinto'0'and'false'.maxWidth,maxHeight, andforceLoadare unchanged.letterSpacingdirectly. Creation already resolves it.Test plan
pnpm vitest run src/core/CoreTextNode.test.tspnpm start, open/?test=text-align, and check left, center, and right