Skip to main content

Bug Tracker

Side navigation

#1730 closed bug (wontfix)

Opened September 26, 2007 12:12AM UTC

Closed September 26, 2007 11:43AM UTC

Last modified October 14, 2008 10:19AM UTC

dynamically created label elements must be closed under IE6

Reported by: simeon Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:
Description

the following code worked under IE6 with JQuery 1.1.2

label = jQuery("<label>").html("foo");

JQuery 1.2.1 only creates the label element if the html closes the tag like

label = jQuery("<label></label>").html("foo");

Both versions work under Firefox 2. This behavior is breaking Jorn Zaefferer's Validation plugin for me...

Attachments (2)
  • patch.2.diff (0.5 KB) - added by simeon September 26, 2007 05:33AM UTC.

    Output of svn diff from trunk directory. Built jquery.js and confirmed that bug is fixed.

  • patch.diff (0.1 KB) - added by simeon September 26, 2007 05:17AM UTC.

    Applied to jquery-1.2.1.js it fixes this bug. Will look into downloading source and applying to core.js

Change History (2)

Changed September 26, 2007 05:12AM UTC by simeon comment:1

Ok, I have a patch but I don't understand all the implications of the code so it may not be optimal...

I tested this with older releases and 1.1.3.1 was the last version that worked. To be clear - the following code produces no output under jquery-1.2.1:

$(document).ready(function(){
 label = jQuery("<label>");
 label.html("Error message2");
 $("body").append(label);
 });

The problem is in the clean() function - as of 1.1.4 and up there's a catch-all for IE that builds the innerHTML of the element being constructed with extra div tags. This breaks the label as the innerHTML property on IE6 ends up having wrapped tags like

<DIV><LABEL></DIV></LABEL>

By adding a specific check for the label tag and using blank wrapper args (see patch) I once again can get the above code to run successfully... My feelings won't be hurt if somebody else wants to take this bug over and solve it some other way - I'm not at all familiar with JQuery (I'm working on it though!)

Changed September 26, 2007 11:43AM UTC by john comment:2

resolution: → wontfix
status: newclosed

Correct, as of jQuery 1.2 you must do: $("<label/>") or $("<label></label>") - we can only accept valid HTML or XHTML. In this case, it's a bug in the form validation plugin - however, looking through the source in SVN, that line doesn't seem to be there any more (it appears as if Joern has fixed it).