Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8413 closed bug (invalid)

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.

Change History (6)

comment:1 Changed 12 years ago by ajpiano

Owner: set to 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.

comment:2 in reply to:  1 Changed 12 years ago by homer8173

Status: pendingnew

Replying to 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.

comment:3 Changed 12 years ago by ajpiano

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

comment:4 Changed 12 years ago by homer8173

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

Last edited 12 years ago by homer8173 (previous) (diff)

comment:5 Changed 12 years ago by ajpiano

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.

Last edited 12 years ago by ajpiano (previous) (diff)

comment:6 Changed 12 years ago by ajpiano

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.