Skip to content
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

Identify inline <style> that's being enqueued to block editor #53756

Open
webmandesign opened this issue Aug 17, 2023 · 2 comments
Open

Identify inline <style> that's being enqueued to block editor #53756

webmandesign opened this issue Aug 17, 2023 · 2 comments
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement.

Comments

@webmandesign
Copy link
Contributor

What problem does this address?

Enqueing stylesheets to block editor using enqueue_block_assets action hook produces inline <style> tags in the editor.

In case of an issue, it is hard to debug as I have to investigate each individual <style> tag to see if my stylesheet was even loaded/enqueued.

What is your proposed solution?

Identify the <style> either with id or data-stylesheet (or similar) attribute like so:

block-editor-styles-identification

@ellatrix
Copy link
Member

Maybe we can add a CSS comment at the top of the stylesheet. I'm worries about attributes as they can be used to target the element in JS, which shouldn't be done. :)

@webmandesign
Copy link
Contributor Author

Well, I thought allowing targeting <style> elements with JS via attribute could be beneficial in case it is needed.
I personally don't have any use for such <style> element manipulation, so I'm perfectly fine with a comment in the code.

I suggest having a comment outside (before) the <style> element so it is fast to identify.

If the comment was inside the element on top, I would need to open each element to read the first comment. As you can see in the example there are already 8 <style> elements which could mean potential mean 8 clicks. You see, I'm lazy :)

@jordesign jordesign added [Type] Enhancement A suggestion for improvement. CSS Styling Related to editor and front end styles, CSS-specific issues. labels Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants