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

addGlobalAttributes style converts style="" to style="0" #2058

Closed
1 of 2 tasks
iain-en opened this issue Oct 19, 2021 · 2 comments
Closed
1 of 2 tasks

addGlobalAttributes style converts style="" to style="0" #2058

iain-en opened this issue Oct 19, 2021 · 2 comments
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@iain-en
Copy link

iain-en commented Oct 19, 2021

What’s the bug you are facing?

I'm using an extension to add style as a global attribute to a number of Nodes, via addGlobalAttributes.

When an HTML tag with and empty style tag style="" is parsed, it's being rendered as style="0".

<p style="0">test paragraph</p>

Here's a simplified example using just paragraphs:
https://codesandbox.io/s/epic-rubin-21irr?file=/src/App.vue

I can fix this using renderHTML, though I don't quite understand why because I'm just returning null

How can we reproduce the bug on our side?

See my CodeSandbox
https://codesandbox.io/s/epic-rubin-21irr?file=/src/App.vue

Can you provide a CodeSandbox?

https://codesandbox.io/s/epic-rubin-21irr?file=/src/App.vue

What did you expect to happen?

<p style="">test paragraph</p>

Anything to add? (optional)

If there's a better way to enable common HTML tag attributes like style, class, id on every Node type then I'd be happy to hear it

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@iain-en iain-en added the Type: Bug The issue or pullrequest is related to a bug label Oct 19, 2021
@hanspagel
Copy link
Contributor

As a workaround: Try returning '' instead of null.

@iain-en
Copy link
Author

iain-en commented Oct 19, 2021

@hanspagel - thanks, but this actually works OK:
renderHTML: (attributes) => { return { style: attributes["style"] || null }; }

This doesn't work though:
renderHTML: (attributes) => { return { style: attributes["style"] }; }

Which is strange because attributes["style"] === null when I check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

2 participants