Ticket #1159 (closed defect: fixed)
findContainingTiddler doesn't work with popups
| Reported by: | EricShulman | Owned by: | MartinBudden |
|---|---|---|---|
| Priority: | undefined | Milestone: | 2.6 |
| Component: | core | Version: | |
| Severity: | undefined | Keywords: | |
| Cc: |
Description
The standard core function, story.findContainingTiddler(elem), does not currently work if invoked from content displayed in a TW popup. This is because the popup DIV itself is actually a child of the document body element, rather than the tiddler in which the popup's 'root element' was rendered.
The current code for findContainingTiddler() is:
Story.prototype.findContainingTiddler = function(e)
{
while(e && !hasClass(e,"tiddler"))
e = e.parentNode;
return e;
};
The following change will add the ability find the containing tiddler when starting from within a popup:
Story.prototype.findContainingTiddler = function(e)
{
while(e && !hasClass(e,"tiddler"))
e = hasClass(e,"popup")?Popup.stack[0].root:e.parentNode;
return e;
};
Basically, it will follow the 'parentNode' branch as usual, unless it encounters a popup... in which case, it uses the popup stack's associated root element instead of the parentNode (which, for a popup would just be the document.body element)
