-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
RichTextData: use a private property #58557
Conversation
this.originalHTML || | ||
toHTMLString( { value: this[ RichTextInternalData ] } ) | ||
); | ||
return this.originalHTML || toHTMLString( { value: this.#value } ); |
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.
The way how originalHTML
is defined in fromHTMLElement
is not entirely correct. It effectively creates a live binding between the htmlElement
and the RichTextData
value. If the element's contents change, then toHTMLString()
will read the latest .innerHTML
value in the getter.
Other parts of the RichTextData
value are however not live: the toPlainText
method, the .text
getter, etc. The object's content can be inconsistent and out of sync.
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.
RichTextData should not be mutable
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.
Then we need to read htmlElement.innerHTML
only once in RichTextData
constructor, not on every call of .toHTMLString
.
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 do it only once in the static method? originalHTML
is a value not a getter?
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.
Or do you mean toHTMLString()
? We shouldn't calculate it in the constructor for performance, we sure we could cache it here for the next call
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 only want to serialise when it's needed)
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.
originalHTML
is a value not a getter?
Oh, somehow I overlooked this 🙂 It's alright then.
I have tried this but it didn't work for me. Would be cool if it works :) |
Oh, TypeScript makes a complaint I don't understand:
because we define |
Size Change: -19 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
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.
Very nice :)
I fixed the TypeScript error. It was the Maybe @noahtallen or @sirreal know a way how to make |
The goal is to run |
Yes, the goal is to typecheck one specific file with a config for a particular project. |
Hello, I am getting "SyntaxError: Invalid character: '#'" on Safari IOS 14.3 and I have narrowed it down to this MR. It seems to work correctly on any other browser I have tested (Windows and Android). I am not sure if I should create a new Issue |
In
RichTextData
, use a private class instance property for the private data, instead of a symbol-indexed public property. Private properties are now standard, they should work.