mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2024-11-23 15:57:54 -05:00
Preserve already present title attribute in time tags.
Also extract isTime check to avoid duplication.
This commit is contained in:
parent
c8ca83c78d
commit
92e8705144
1 changed files with 6 additions and 4 deletions
|
@ -96,10 +96,12 @@
|
||||||
return new Date(s);
|
return new Date(s);
|
||||||
},
|
},
|
||||||
datetime: function(elem) {
|
datetime: function(elem) {
|
||||||
// jQuery's `is()` doesn't play well with HTML5 in IE
|
var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
|
||||||
var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
|
|
||||||
var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
|
|
||||||
return $t.parse(iso8601);
|
return $t.parse(iso8601);
|
||||||
|
},
|
||||||
|
isTime: function(elem) {
|
||||||
|
// jQuery's `is()` doesn't play well with HTML5 in IE
|
||||||
|
return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -127,7 +129,7 @@
|
||||||
if (!element.data("timeago")) {
|
if (!element.data("timeago")) {
|
||||||
element.data("timeago", { datetime: $t.datetime(element) });
|
element.data("timeago", { datetime: $t.datetime(element) });
|
||||||
var text = $.trim(element.text());
|
var text = $.trim(element.text());
|
||||||
if (text.length > 0) {
|
if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
|
||||||
element.attr("title", text);
|
element.attr("title", text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue