#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 10 years ago by
Owner: | set to reda |
---|---|
Status: | new → pending |
comment:3 Changed 10 years ago by
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 10 years ago by
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 10 years ago by
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 10 years ago by
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:8 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
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
Can you provide an example using jsfiddle.net?