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

Add support for normalising tag names #11

Closed
wooorm opened this issue May 27, 2019 · 1 comment · Fixed by #12
Closed

Add support for normalising tag names #11

wooorm opened this issue May 27, 2019 · 1 comment · Fixed by #12
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🧑 semver/major This is a change 🦋 type/enhancement This is great to have

Comments

@wooorm
Copy link
Member

wooorm commented May 27, 2019

Subject of the issue

Just like with properties, tag names should be normalised and fixed:

Tags contain a tag name, giving the element's name. HTML elements all have names that only use ASCII alphanumerics. In the HTML syntax, tag names, even those for foreign elements, may be written with any mix of lower- and uppercase letters that, when converted to all-lowercase, matches the element's tag name; tag names are case-insensitive.

We could lower-case all tag names. Even those for SVG, because of the reasons given in the above quote.
However, it makes more sense to me to use the proper name as defined by SVG, such as textPath instead of textpath.

Your environment

  • OS: n/a
  • Packages: hastscript@5.0.1
  • Env: n/a

Steps to reproduce

var h = require('hastscript')
console.log(h('DIV'))

Expected behaviour

{children: [], properties: Object {}, tagName: 'div', type: 'element'}

Actual behaviour

{children: [], properties: Object {}, tagName: 'DIV', type: 'element'}
wooorm added a commit that referenced this issue May 28, 2019
See:

*   <https://html.spec.whatwg.org/multipage/parsing.html#tag-name-state>

    The HTML tokenizer consumes ASCII upper alpha as lower alpha
*   <https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign>

    SVG in HTML is therefore first lowercased, and afterwards has to
    be adjusted
*   <https://github.com/syntax-tree/hast#element>

    The hast spec already described the local name must be used on
    elements

Closes GH-11.
wooorm added a commit that referenced this issue May 28, 2019
See:

*   <https://html.spec.whatwg.org/multipage/parsing.html#tag-name-state>

    The HTML tokenizer consumes ASCII upper alpha as lower alpha
*   <https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign>

    SVG in HTML is therefore first lowercased, and afterwards has to
    be adjusted
*   <https://github.com/syntax-tree/hast#element>

    The hast spec already described the local name must be used on
    elements

Closes GH-11.
Closes GH-12.
@wooorm wooorm added ⛵️ status/released 🗄 area/interface This affects the public interface 🦋 type/enhancement This is great to have 🧑 semver/major This is a change labels Aug 11, 2019
@wooorm wooorm changed the title Tag names should be normalised Add support for normalising tag names Aug 11, 2019
@wooorm wooorm added the 💪 phase/solved Post is done label Apr 12, 2021
@mordechaim
Copy link

mordechaim commented Dec 26, 2023

I can confirm that the lowercasing of textPath breaks the SVG. It no longer draws text on the path.

As a workaround, I rename the tagName immediately after creation with h().

EDIT: I see, I'm supposed to use s()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🧑 semver/major This is a change 🦋 type/enhancement This is great to have
Development

Successfully merging a pull request may close this issue.

2 participants