#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:2 Changed 11 years ago by
Component: | unfiled → offset |
---|---|
Owner: | set to mccaskey |
Priority: | undecided → low |
Status: | new → pending |
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
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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!
Update: I expected Chrome would be fine with document.getElementsByTagName('body')[0].clientTop, but it isn't. It wants body.clientTop.