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

Table manipulation regression (XHTML) #2493

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

Table manipulation regression (XHTML) #2493

anthonyryan1 opened this issue Jul 23, 2015 · 2 comments

Comments

@anthonyryan1
Copy link
Contributor

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
Copy link
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
Copy link
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?

anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Jul 25, 2015
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 jquerygh-2031, jquerygh-2002
Closes jquerygh-2493
anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Jul 25, 2015
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 jquerygh-2031, jquerygh-2002
Closes jquerygh-2493
anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Sep 9, 2015
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 jquerygh-2031, jquerygh-2002
Closes jquerygh-2493
anthonyryan1 added a commit to anthonyryan1/jquery that referenced this issue Sep 9, 2015
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 jquerygh-2031, jquerygh-2002
Closes jquerygh-2493
@mgol mgol added this to the 3.0.0 milestone Sep 14, 2015
@mgol mgol closed this as completed in 99e8ff1 Sep 14, 2015
mgol pushed a commit that referenced this issue Sep 14, 2015
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
@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.
Development

No branches or pull requests

4 participants