Details
-
Bug
-
Resolution: Won't Fix
-
High
-
None
-
5.1
-
None
-
5.01
-
Description
The NEW_CONTENT_ADDED event is fired when new content is added to the dom. Its 'context' parameter is the DOM node that was actually added.
The contract of this event is that it will never be fired for the same dom node twice, including parent relationships.
So, for example, if a node exists in the DOM tree and we fire NEW_CONTENT_ADDED on its parent, we can never fire for a child that existed at that time. We can only fire the event when new content is actually added to the tree, and the context is strictly the node that was added.
It's been reported that developers have seen this incorrect behaviour occurring. Two bug fixes have been made based on this behaviour:
- https://github.com/atlassian/jira-suite-utilities/commit/86adec5723987f64955beca858c7d518a73975d1#L4R58
- https://bitbucket.org/atlassian/jiraconnect-jiraplugin/changeset/34ab84f71698
- and apparently one in the drag and drop plugin. Speak to cdoble to find out where.
We should investigate to see if NEW_CONTENT_ADDED is being fired twice on the same dom node - if so this is a bug that will affect all plugin devs and must be fixed.
This code might help detect the bug - it will log an error message to the console if NEW_CONTENT_ADDED is seen twice for a node in the given context.
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, $ctx, reason) { var $els = $ctx.find("*").andSelf(); if ($els.filter(".i-have-been-seen").length) { console.log("OHNOES - it's a NEW_CONTENT_ADDED bug"); } $els.addClass("i-have-been-seen"); });
Attachments
Issue Links
- causes
-
JRASERVER-42752 JIRA.Events.NEW_CONTENT_ADDED event is triggered twice when reloading/refreshing an issue
- Gathering Impact
- details
-
JRASERVER-29137 Fix incorrect firing of NEW_CONTENT_ADDED in TabManager.js
- Closed
-
JRASERVER-29144 Fix incorrect firing of NEW_CONTENT_ADDED in Quick Edit
- Closed