Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14673 closed bug (notabug)

The after() method removes element instead of inserting it

Reported by: reda Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

Here is how to reproduce:

//element is a jQuery element (present in the DOM).
$('<div></div>').after(element);  
//element is no more in the DOM

The bug is found starting from v1.9.1 until the latest (2.0.3)

jQuery 1.8.3 is OK.

Change History (9)

comment:1 Changed 6 years ago by dmethvin

Owner: set to reda
Status: newpending

Can you provide an example using jsfiddle.net?

comment:2 Changed 6 years ago by reda <reda.abdi@…>

comment:3 Changed 6 years ago by dmethvin

What was your expected outcome? The <div /> is disconnected from the document and you're adding #x to the set after that. Notice that in 1.8.3 the <div> doesn't actually go anywhere after this executed.

This is definitely a behavior change that occurred at 1.9 but I'm trying to understand why the code would need this behavior and what it does.

comment:4 Changed 6 years ago by reda <reda.abdi@…>

I spotted this behavior change because a widget stopped working when upgrading jquery version.

The widget I am using is from a library (an old version) that does nothing important with the after() method and I can easily stop using the after() method.

It is up to you now to investigate further to see if this behavior change was done deliberately or not.

Thanks for your active support.

comment:5 Changed 6 years ago by dmethvin

What is the name of the widget? Can you point to the code in question?

The behavior change was deliberate but again I'd like to know more about what the caller was expecting. The code snippet as shown was a no-op in 1.8.3 and I suspect it was actually trying to do something.

comment:6 Changed 6 years ago by reda <reda.abdi@…>

The library is:

https://github.com/emposha/FCBKcomplete/blob/master/jquery.fcbkcomplete.js

The version I am using is 2.8.5 (run a git log on the repo if you like to check it)

The current version doesn't contain the culprit call to the after() method:

                var json_cache = $('<div></div>').after(element);
      		var json_cache_object = {
        		'set': function (id, val) {
          			json_cache.data(id, val);
        		},
        		'get': function(id) {
          			return json_cache.data(id);
        		}
      		}

Thanks

comment:7 Changed 6 years ago by dmethvin

Owner: reda deleted
Status: pendingnew

Thanks for the info!

comment:8 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

The change was committed here, with no description of why. I am going to assume they were just misusing the API, realized a problem, and that's why they changed it.

https://github.com/emposha/FCBKcomplete/commit/95bdc472f073f7c6ab0cd87741d5934c5aab08c3

comment:9 Changed 6 years ago by anonymous

@dmethvin Well done. Thanks!

Note: See TracTickets for help on using tickets.