Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#13210 closed bug (invalid)

body in XML in Firefox

Reported by: mccaskey Owned by: mccaskey
Priority: low Milestone: None
Component: offset Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:

Description

Using jQuery 1.8.3, with this xslt file, bodyBug.xsl,

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    
    <xsl:output method="xml" indent="no" encoding="utf-8" />
    
    <xsl:template match ="/">
        <html xmlns="http://www.w3.org/1999/xhtml"> 
            
            <head>
                <title>jQuery body bug</title>
                
                <script type="text/javascript" src="jquery.1.8.3.js" ></script>
                <script type="text/javascript" src="bodyBug.js"></script>
                   
            </head>
            <body>
                <xsl:apply-templates />
            </body>
            
        </html>
    </xsl:template>
    
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

and this xml file

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="bodyBug.xsl"  ?>

<t>
    <c>Hello</c>
    <c>World</c>
</t>

this js file, bodyBug.js,

jQuery(window).load(function(){
    alert($('c').offset().top);
});

should alert a number when the xml file is opened.

In Chrome it does, but in Firefox it does not. This error gets logged to the console:

TypeError: body is undefined
clientTop  = docElem.clientTop  || body.clientTop  || 0;

It will, however, work fine if

body.clientTop

is replaced with

document.getElementsByTagName("body")[0].clientTop

or if the xsl output is set to "html".

So somewhere jQuery is relying on the special meaning that "body" has in an html file that it does not automatically have in an xml file (at least not in Firefox).

Change History (4)

comment:1 Changed 11 years ago by mccaskey

Update: I expected Chrome would be fine with document.getElementsByTagName('body')[0].clientTop, but it isn't. It wants body.clientTop.

Version 0, edited 11 years ago by mccaskey (next)

comment:2 Changed 11 years ago by dmethvin

Component: unfiledoffset
Owner: set to mccaskey
Priority: undecidedlow
Status: newpending

The body there is a local var for the document.documentElement.body property. So yes, it looks like we'd need to use DOM methods to "find" the body for XML documents if we wanted to make that work. Is there a reason you need to set the output to XML? I'd be surprised if this is the only issue with processing a pure XML document and asking HTML-like things about it.

comment:3 Changed 11 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:4 Changed 11 years ago by dmethvin

Still waiting on followup from poster.

Note: See TracTickets for help on using tickets.