Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#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:
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.diff (68 bytes) - added by simeon 13 years ago.
Applied to jquery-1.2.1.js it fixes this bug. Will look into downloading source and applying to core.js
patch.2.diff (482 bytes) - added by simeon 13 years ago.
Output of svn diff from trunk directory. Built jquery.js and confirmed that bug is fixed.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 13 years ago by simeon

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 13 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 13 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 13 years ago by john

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

Note: See TracTickets for help on using tickets.