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

Table manipulation regression (XHTML) #2493

Closed
anthonyryan1 opened this Issue Jul 23, 2015 · 2 comments

Comments

Projects
None yet
4 participants
@anthonyryan1
Contributor

anthonyryan1 commented Jul 23, 2015

jQuery 3.0 introduced an XHTML regression in the appending and updating of table rows, it appears the outermost element in every .append(), .html(), .load(), etc gets removed and only the contents of that outermost element are actually appended or set as the innerHTML.

Simple test case (requires Content-type: application/xhtml+xml; charset=utf-8; to properly demonstrate the regression)

<!-- fill in doctype, html, head, body, etc. -->
<table>
<thead>
    <tr>
        <th>One</th>
        <th>Two</th>
        <th>Three</th>
    </tr>
</thead>
<tbody id="append"></tbody>
</table>
$(document).ready(function(){
    $('#append').append('<tr><td>Four</td><td>Five</td><td>Six</td></tr>');
    $('#append').append('<tr><td>Seven</td><td>Eight</td><td>Nine</td></tr>');
});

In XHTML mode, the resulting DOM is the equivalent of:

<table>
<thead>
    <tr>
        <th>One</th>
        <th>Two</th>
        <th>Three</th>
    </tr>
</thead>
<tbody id="append">
    <td>Four</td>
    <td>Five</td>
    <td>Six</td>
    <td>Seven</td>
    <td>Eight</td>
    <td>Nine</td>
</tbody>
</table>

I've also noticed the XHTML test harness is once again broken and likely how this regression occurred, but that's outside the scope of this issue.

@mr21

This comment has been minimized.

Show comment
Hide comment
@mr21

mr21 Jul 23, 2015

Contributor

If I test this in chrome:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<script src="https://code.jquery.com/jquery-3.0.0-alpha1.js"></script>

</head>
<body>

<table>
    <thead>
        <tr>
            <th>1</th>
            <th>2</th>
            <th>3</th>
        </tr>
    </thead>
    <tbody id="append"></tbody>
</table>

<script>

$( "#append" )
    .append( "<tr><td>4</td><td>5</td><td>6</td></tr>" )
    .append( "<tr><td>7</td><td>8</td><td>9</td></tr>" )
;

</script>
</body>
</html>

There is no problem.

We can't use <meta> with jsfiddle :(

Contributor

mr21 commented Jul 23, 2015

If I test this in chrome:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<script src="https://code.jquery.com/jquery-3.0.0-alpha1.js"></script>

</head>
<body>

<table>
    <thead>
        <tr>
            <th>1</th>
            <th>2</th>
            <th>3</th>
        </tr>
    </thead>
    <tbody id="append"></tbody>
</table>

<script>

$( "#append" )
    .append( "<tr><td>4</td><td>5</td><td>6</td></tr>" )
    .append( "<tr><td>7</td><td>8</td><td>9</td></tr>" )
;

</script>
</body>
</html>

There is no problem.

We can't use <meta> with jsfiddle :(

@dmethvin

This comment has been minimized.

Show comment
Hide comment
@dmethvin

dmethvin Jul 25, 2015

Member

The doc has to be served with the right content-type tho as @anthonyryan1 said, otherwise it won't be xhtml.

Looks like we can't do 0ea342a because of xhtml?

Member

dmethvin commented Jul 25, 2015

The doc has to be served with the right content-type tho as @anthonyryan1 said, otherwise it won't be xhtml.

Looks like we can't do 0ea342a because of xhtml?

anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Jul 25, 2015

Manipulation: Don't provide the parser with sloppy table markup
While we can reply on parsers that were designed to cope with
malformed syntax to understand what we mean, we shouldn't
intenitonally provide bad markup, not all parsers will accept
it.

"Be conservative in what you do, be liberal in what you accept
from others."

Reverts 0ea342a
See also gh-2031, gh-2002
Closes gh-2493

anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Jul 25, 2015

Manipulation: Don't provide the parser with sloppy table markup
While we can reply on parsers that were designed to cope with
malformed syntax to understand what we mean, we shouldn't
intentionally provide bad markup, not all parsers will accept
it.

"Be conservative in what you do, be liberal in what you accept
from others."

Reverts 0ea342a
See also gh-2031, gh-2002
Closes gh-2493

anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Sep 9, 2015

Manipulation: Don't provide the parser with sloppy table markup
While we can reply on parsers that were designed to cope with
malformed syntax to understand what we mean, we shouldn't
intentionally provide bad markup, not all parsers will accept
it.

"Be conservative in what you do, be liberal in what you accept
from others."

Reverts 0ea342a
See also gh-2031, gh-2002
Closes gh-2493

anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Sep 9, 2015

Manipulation: Don't provide the parser with sloppy table markup
While we can reply on parsers that were designed to cope with
malformed syntax to understand what we mean, we shouldn't
intentionally provide bad markup, not all parsers will accept
it.

"Be conservative in what you do, be liberal in what you accept
from others."

Reverts 0ea342a
See also gh-2031, gh-2002
Closes gh-2493

@mgol mgol added this to the 3.0.0 milestone Sep 14, 2015

@mgol mgol closed this in 99e8ff1 Sep 14, 2015

mgol added a commit that referenced this issue Sep 14, 2015

Manipulation: Don't provide the parser with sloppy table markup
While we can reply on parsers that were designed to cope with
malformed syntax to understand what we mean, we shouldn't
intentionally provide bad markup, not all parsers will accept
it.

"Be conservative in what you do, be liberal in what you accept
from others."

(cherry-picked from 99e8ff1)

Reverts 0ea342a

Refs gh-2031
Refs gh-2002
Fixes gh-2493
Closes gh-2499

@dmethvin dmethvin modified the milestones: 1.12/2.2, 3.0.0 Jan 8, 2016

@cssmagic cssmagic referenced this issue May 18, 2016

Open

jQuery #5

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.