Skip to content

Commit

Permalink
feat(popup): use title attribute as very last option only
Browse files Browse the repository at this point in the history
When an element got a predefined popup as direct sibling and also got a "title" attribute, the predefined popup was ignored

The title attribute should be the very last option to gain the possible popup content.
  • Loading branch information
lubber-de authored Mar 17, 2023
1 parent 3a3d6aa commit 11b4099
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@
// generates popup html from metadata
create: function () {
var
targetSibling = $target.next(selector.popup),
contentFallback = !settings.popup && targetSibling.length === 0 ? $module.attr('title') : false,
html = module.get.html(),
title = module.get.title(),
content = module.get.content()
content = module.get.content(contentFallback)
;

if (html || content || title) {
Expand Down Expand Up @@ -291,10 +293,10 @@
if (settings.hoverable) {
module.bind.popup();
}
} else if ($target.next(selector.popup).length > 0) {
} else if (targetSibling.length > 0) {
module.verbose('Pre-existing popup found');
settings.inline = true;
settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
settings.popup = targetSibling.data(metadata.activator, $module);
module.refresh();
if (settings.hoverable) {
module.bind.popup();
Expand Down Expand Up @@ -484,10 +486,10 @@

return $module.data(metadata.title) || settings.title;
},
content: function () {
content: function (fallback) {
$module.removeData(metadata.content);

return $module.data(metadata.content) || settings.content || $module.attr('title');
return $module.data(metadata.content) || settings.content || fallback;
},
variation: function () {
$module.removeData(metadata.variation);
Expand Down

0 comments on commit 11b4099

Please sign in to comment.