Skip to content

Support case-sensitive HTML elements #140

@marcoroth

Description

@marcoroth

Even while it's encouraged to use Kebab-case for HTML-tags there are some use-cases where we have case-sensitive HTML elements, like in SVG (see #139). This would also allow to cleanup the special-handling we have for handling SVG elements in:

subchild.name = SVG_ELEMENTS[subchild.name] if SVG_ELEMENTS.key?(subchild.name)

Since we are using Nokogiri::HTML4::DocumentFragment for parsing the source it automatically casts all tag names to lowercase. While Nokogiri::HTML5::DocumentFragment would support case-sensitive tags, it doesn't support other things like properly detecting boolean attributes (see #119 and #120).

ERB Input:

<customElement>
 <anotherElement/>
</customElement>

Output:

class CustomelementComponent < Phlex::HTML
  register_element :anotherelement
  register_element :customelement

  def template
    customelement { anotherelement }
  end
end

Expected output:

class CustomelementComponent < Phlex::HTML
  register_element :anotherElement
  register_element :customElement

  def template
    customElement { anotherElement }
  end
end

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions