Skip to main content

Bug Tracker

Side navigation

#12581 closed bug (notabug)

Opened September 20, 2012 03:07PM UTC

Closed September 20, 2012 03:14PM UTC

Last modified September 20, 2012 03:25PM UTC

IE8 append to must have a closing tag

Reported by: theallan Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.1
Keywords: Cc:
Blocked by: Blocking:
Description

Its very handy to be able to create HTML tags with the jQuery 'selector' but, it seems that IE8 requires the closing tag is some circumstances and not others (specifically it is needed when passed into append, but not the main selector)

$('#one').append('<span>'); // Its this one which is not being inserted

$('#one').append('<span></span>');

$('<span>').appendTo('#three');

$('<span></span>').appendTo('#four');

http://jsfiddle.net/xhMuy/5/

Its obviously easy to close the tag off, but I'd have expected the interface for the two method used here to have the same outcome.

Attachments (0)
Change History (4)

Changed September 20, 2012 03:14PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

Not only is it easy, but it makes the HTML correct. I think that's the problem with trying to correct bad input. Once we do it one place, people expect it to be corrected everywhere. We corrected $("<simpletag >") because it could be done cheaply, but I don't think we want to attempt an W3C HTML Validator for all input HTML arguments in jQuery.

Changed September 20, 2012 03:19PM UTC by theallan comment:2

The documentation says:

The .append() and .appendTo() methods perform the same task

However, they apparently don't perform the same task. I agree that it should probably always just require valid input, but the difference between the two methods is what caught me off guard. Can they not be harmonised?

Changed September 20, 2012 03:20PM UTC by dmethvin comment:3

Well they perform the same task for valid inputs. What they do with invalid inputs may differ.

Changed September 20, 2012 03:25PM UTC by theallan comment:4

:-). Fair enough! Thanks for the feedback.