Skip to main content

Bug Tracker

Side navigation

#13210 closed bug (invalid)

Opened January 14, 2013 10:48PM UTC

Closed February 10, 2013 08:58AM UTC

Last modified February 10, 2013 01:46PM UTC

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).

Attachments (0)
Change History (4)

Changed January 14, 2013 11:28PM UTC by mccaskey comment:1

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

Changed January 26, 2013 07:48PM UTC by dmethvin comment:2

component: unfiledoffset
owner: → 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.

Changed February 10, 2013 08:58AM UTC by trac-o-bot comment:3

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!

Changed February 10, 2013 01:46PM UTC by dmethvin comment:4

Still waiting on followup from poster.