Ticket #1730 (closed bug: wontfix)
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: | ||
| Blocking: | Blocked by: |
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
Change History
Changed 6 years ago by simeon
-
attachment
patch.diff
added
Applied to jquery-1.2.1.js it fixes this bug. Will look into downloading source and applying to core.js
Changed 6 years ago by simeon
-
attachment
patch.2.diff
added
Output of svn diff from trunk directory. Built jquery.js and confirmed that bug is fixed.
comment:2 Changed 6 years ago by john
- Status changed from new to closed
- Resolution set to wontfix
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).
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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