-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove and prevent DOM access in attributes parsing #608
Comments
I think the duplication for the examples above is acceptable, thus, I'd go for the first proposal for now. |
If we're not using HTML as the source of truth then why are we even using HTML at all? Don't we lose most of the benefits of serializing to HTML if we don't respect edits to the HTML content from other sources? I'd very much prefer that we avoid duplicating information here. So far this means that we need a way to match patterns inside class names. Anything else we're already aware of? |
Other benefits of serializing to HTML include viewability, portability, and long-term meaningfulness (should the block's implementing plugin later be uninstalled). But I would agree that to the extent possible, it should be a goal to respect edits made externally and avoid duplication. The original Editor Technical Overview highlights these objectives well, though doesn't make entirely clear whether duplicating in the comment block is necessarily as bad as in post meta, since it's technically within markup of the post, and both visible and editable by external editors (assuming they know how to).
Currently that seems to be all. Of the blocks we've implemented, those with comment attributes include two relying on classname (quote, image) and one which will eventually depend on server-rendering (embed). https://github.com/WordPress/gutenberg/blob/master/post-content.js |
Maybe they don't need to be class names though. Specifically for images there are implications here on backwards compatibility with |
I don't have a strong preference for how/where this data is stored, class names seems the most straightforward or obvious way but Elaborating a bit on my previous comment, here is the sort of breakage I imagine from not treating HTML as the source of truth:
|
In an effort to avoid tying block parsing to the DOM, we should not expect block implementers to provide custom matchers for attribute parsing.
Examples:
Instead, we should decide between:
To discourage taking advantage of matchers currently receiving the DOM node, we could consider adding an internal flag, and picking only keys from the block
attributes
property whose values are an allowable matcher.The text was updated successfully, but these errors were encountered: