-
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
Add block attribute selector for inline style #9439
Comments
I can see how this helps eliminate the duplication but we want to keep the matchers as limited as possible to allow an eventual php implementation of these matchers in the future. I don't really think duplication in this case is harmful in any case. I'd be in favor of closing this issue for now. |
The PHP implementation could read the style properties too, no? |
@westonruter yes it could, but given how fragile it is to parse HTML in PHP, It's safer to keep the matchers to the minimum possible set IMO (for now at least). |
Wouldn't the HTML be parsed via |
There’s also some related discussion in #11212 and #10444. I think ultimately it comes down to the philosophical question of whether the markup is ultimately an artefact, like the output of a build tool, or itself an intrinsic part of the block’s “identity”? Closely coupling data with its position in the markup makes it harder for the markup structure to change, and makes it harder to represent a block outside of an HTML context. (I recognise there are some places where we have to store block data in markup, e.g. inner blocks and RichText, but it’s not hard to imagine a future when that changes too and an entire block tree can be interpreted without parsing markup.) |
I actually did this in #10074, but didn't see this issue at the time, so didn't link the two together. Some information on why it never went ahead was commented by @aduth:
Is it worth keeping this issue open? |
I think the majority of discussion here has been unfavorable / skeptical. The issue can be reopened if there's further compelling arguments, but for now it does not appear to be actionable. |
In ampproject/amp-wp#1380 a background color attribute was added to a block. The attribute is defined as:
The static markup generated by the
save
function includes this:Notice the duplication of the color.
Has there been discussion of adding a block attribute selector for inline styles? I know that inline styles have been disfavored at times, so maybe this isn't a good idea. But for this case it would eliminate the duplication.
Consider if the
backgroundColor
attribute could be defined instead as follows:Then the static markup could eliminate the duplication and be stored instead as:
The text was updated successfully, but these errors were encountered: