Skip to content

version 4.0.0 render_inline in specs issues #2422

@martinechtner

Description

@martinechtner

When rendering a component for a table row in specs it strips out the <tr> and <td> tags.

Steps to reproduce

Easily reproducible in rails console:

# without `<table>`
str = '<tr class="text-gray-500"><td>some content</td></tr>'
Nokogiri::HTML5.fragment(str)

=> #(DocumentFragment:0x269f8 { name = "#document-fragment", children = [ #(Text "some content")] })

# with `<table>`
str = '<table><tr class="text-gray-500"><td>some content</td></tr></table>'
Nokogiri::HTML4.fragment(str)

=> 
#(DocumentFragment:0x26fb0 {
  name = "#document-fragment",
  children = [
    #(Element:0x27028 {
      name = "table",
      children = [
        #(Element:0x270a0 {
          name = "tbody",
          children = [ #(Element:0x27118 { name = "tr", attribute_nodes = [ #(Attr:0x27190 { name = "class", value = "text-gray-500" })], children = [ #(Element:0x27268 { name = "td", children = [ #(Text "some content")] })] })]
          })]
      })]
  })

Expected behavior

I would expect it would render the component as is.

Actual behavior

Strips out the ill-formed HTML tags

Backtrace:

System configuration

Rails version: 7.2.2.1

Ruby version: 3.4.5

Gem version: 4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions