Skip to content

Commit 11b4099

Browse files
authored
feat(popup): use title attribute as very last option only
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.
1 parent 3a3d6aa commit 11b4099

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/definitions/modules/popup.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@
248248
// generates popup html from metadata
249249
create: function () {
250250
var
251+
targetSibling = $target.next(selector.popup),
252+
contentFallback = !settings.popup && targetSibling.length === 0 ? $module.attr('title') : false,
251253
html = module.get.html(),
252254
title = module.get.title(),
253-
content = module.get.content()
255+
content = module.get.content(contentFallback)
254256
;
255257

256258
if (html || content || title) {
@@ -291,10 +293,10 @@
291293
if (settings.hoverable) {
292294
module.bind.popup();
293295
}
294-
} else if ($target.next(selector.popup).length > 0) {
296+
} else if (targetSibling.length > 0) {
295297
module.verbose('Pre-existing popup found');
296298
settings.inline = true;
297-
settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
299+
settings.popup = targetSibling.data(metadata.activator, $module);
298300
module.refresh();
299301
if (settings.hoverable) {
300302
module.bind.popup();
@@ -484,10 +486,10 @@
484486

485487
return $module.data(metadata.title) || settings.title;
486488
},
487-
content: function () {
489+
content: function (fallback) {
488490
$module.removeData(metadata.content);
489491

490-
return $module.data(metadata.content) || settings.content || $module.attr('title');
492+
return $module.data(metadata.content) || settings.content || fallback;
491493
},
492494
variation: function () {
493495
$module.removeData(metadata.variation);

0 commit comments

Comments
 (0)