Bug Tracker

Ticket #8413 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

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:
Blocking: Blocked by:

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

comment:1 follow-up: ↓ 2 Changed 4 years ago by ajpiano

  • Owner set to homer8173
  • Status changed from new to pending

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 4 years ago by homer8173

  • Status changed from pending to new

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 4 years ago by ajpiano

  • Status changed from new to pending

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 4 years ago by homer8173

  • Status changed from pending to new

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 4 years ago by homer8173 (previous) (diff)

comment:5 Changed 4 years ago by ajpiano

  • Component changed from unfiled to manipulation

 .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 4 years ago by ajpiano (previous) (diff)

comment:6 Changed 4 years ago by ajpiano

  • Status changed from new to closed
  • Resolution set to invalid
Note: See TracTickets for help on using tickets.