-
Notifications
You must be signed in to change notification settings - Fork 17
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
Consider data model immutability (and one-step construction) #23
Comments
@nhelfman could you provide a bit of example code that demonstrates this? |
For example, instead of: let text = new FormattedText();
text.textruns.push (new FormattedTextRun({ text: "hello" });
text.textruns.push (new FormattedTextRun(" world");
text.textruns[1].tstyleMap.set("text-decoration", "underline"); It could be declared as: let text = new FormattedText([
{ text: "hello" },
{ text: " world", style: { "text-decoration": "underline" }
]
); Then, if we define |
Your second example is almost fully supported by the current data model (see the 3rd constructor overload in the WebIDL): constructor(sequence<FormattedTextRunInit> textRunInit); however, it expects a single string with the style declarations--there is some internal discussion about whether that should be used (e.g., requires the CSS parser to run on the string). Your approach with a record type of <css name string/ css value string> seems better. The comment about making the data model immutable is more interesting. I'd been always thinking about Mutability seems convenient if you use the |
Closing this as PR #39 does away with the intermediary "data model" and now depends on application logic to host their own data model, which must be arranged correctly to a call to |
I think it would be much easier to use the API if we can pass the whole model to the FormattedText constructor as an array instead of setting each run stylemap on separate statements. Is there also potential perf gain with that idea?
@nhelfman
The text was updated successfully, but these errors were encountered: