[wp-trac] [WordPress Trac] #59673: Add viewStyle block.json property for frontend-only block styles

WordPress Trac noreply at wordpress.org
Wed Jan 31 09:34:09 UTC 2024


#59673: Add viewStyle block.json property for frontend-only block styles
-----------------------------------------------------+---------------------
 Reporter:  gaambo                                   |       Owner:  gziolo
     Type:  enhancement                              |      Status:  closed
 Priority:  normal                                   |   Milestone:  6.5
Component:  Editor                                   |     Version:  6.4
 Severity:  normal                                   |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests needs-dev-note  |     Focuses:
-----------------------------------------------------+---------------------

Comment (by gaambo):

 Thank you very much @gziolo!

 >> I didn't add any special handling for core blocks, since no core block
 uses viewStyle obviously. But in the future that might be the case. So I
 think the phpunit tests checking for the correct core styles to be loaded
 in regard to should_load_separate_core_block_assets must be adapted. But
 I'm not fully sure I understand those. Maybe someone can help me with
 that.

 > That one is indeed a complex one. It isn't an issue at the moment, but I
 expect that if we were to use viewStyle for core blocks we would have to
 provide two versions of CSS. The bundled one that would get registered
 separately and the regular one should work out of the box.

 Should this be handled in core or in Gutenberg?


 >> At the moment there are no e2e/phpunit tests which check if
 viewStyle/viewScript get only enqueued in the frontend. Should I add tests
 for that?

 > It would be nice to add unit tests as follow up. I'm not entirely sure
 how to approach it as we would need to print the HTML for a page using
 block theme that renders a custom block that defines viewStyle and
 viewScript. Something, that would be useful in general.

 Same question as above. Also: My experience with writing tests is minimal,
 not sure how we'd build and print HTML in unit tests to account for that.
 I would be glad to help or learn, if somebody is willing to guide me
 through it.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59673#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list