Skip to main content

Bug Tracker

Side navigation

#8413 closed bug (invalid)

Opened March 01, 2011 01:28PM UTC

Closed March 01, 2011 06:01PM UTC

function replaceWith() bug on Internet Explorer 7&8

Reported by: homer8173 Owned by: homer8173
Priority: undecided Milestone: 1.next
Component: manipulation Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

hi,

find a limitation to replaceWith() on non existing elements with IE 7&8.

not tested on other IE, sorry.

the fix we found was to test element size to determinate if exist

For firefox we use :

$("My selector").replaceWith("My new content")

For IE we patched :

if ($("My selector").length>0) $("My selector").replaceWith("My new content");

here is the thread in your forum :

http://forum.jquery.com/topic/ie-replacewith-issue

Perhaps you will not consider this as bug... let me know.

Anyway, thanks for your job.

Attachments (0)
Change History (6)

Changed March 01, 2011 04:05PM UTC by ajpiano comment:1

owner: → homer8173
status: newpending

Thanks for your time and interest in helping the jQuery project. We require that all bugs have a working, reproducible testcase on jsFiddle or another working live demo so that we can audit the bug further. If you can provide that, we can investigate this potential issue further. Thank you.

Changed March 01, 2011 04:24PM UTC by homer8173 comment:2

status: pendingnew

Replying to [comment:1 ajpiano]:

Thanks for your time and interest in helping the jQuery project. We require that all bugs have a working, reproducible testcase on jsFiddle or another working live demo so that we can audit the bug further. If you can provide that, we can investigate this potential issue further. Thank you.

This problem concerning Internet Explorer ONLY, i tried it on jsFiddle but it can't be reproduced there.

Try to put this code in Internet Explorer 7 or 8:

$(document).ready( function () {
      $(window).bind("load", function() {
            $("My selector does not exist").replaceWith("My new content");
      });
});

it was working on Firefox.

Other functions such as append(), html(), etc work fine on non existing selectors.

Changed March 01, 2011 04:36PM UTC by ajpiano comment:3

status: newpending

The fact that this cannot be duplicated in jsFiddle (http://jsfiddle.net/Y779e/) or jsBin (http://jsbin.com/ezaxu4) in IE means that we cannot move forward in diagnosing this potential issue. If you can provide us with a test page in some format, then we may be able to assist - if not, we can't.

For what it's worth, the first line of replaceWith in the jQuery source checks to make sure that there are elements in the wrapped set:

        replaceWith: function(value) {
            if (this[0] && this[0].parentNode) {

Changed March 01, 2011 05:27PM UTC by homer8173 comment:4

_comment0: sorry i m not used to your tools and not realy concentrated, so here is my problem for all browser in fact : \ \ [http://jsbin.com/ezaxu4/3/] \ \ {{{ \ $("h2 sup").replaceWith('®'); \ }}} \ \ error: uncaught exception: Syntax error, unrecognized expression: ® \ it seems only that not very good for coding ... \ \ Sorry for the noize1299000453746016
status: pendingnew

sorry i m not used to your tools and not realy concentrated, so here is my problem for all browser in fact :

http://jsbin.com/ezaxu4/3/

$("h2 sup").replaceWith('®');

error: uncaught exception: Syntax error, unrecognized expression: ®

it seems only that not very good for coding ...

Sorry for the noize

Changed March 01, 2011 05:58PM UTC by ajpiano comment:5

_comment0: [http://api.jquery.com/replaceWith/ .replaceWith] is not documented to support replacing an element with an arbitrary string - it requires an element, an HTML string representing an element, or a jQuery object.1299002427654458
component: unfiledmanipulation

.replaceWith is not designed to support replacing an element with an arbitrary string - it requires an element, an HTML string representing an element, or a jQuery object.

Changed March 01, 2011 06:01PM UTC by ajpiano comment:6

resolution: → invalid
status: newclosed