Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Preserve already present title attribute in time tags.

Also extract isTime check to avoid duplication.
  • Loading branch information...
commit 92e87051445e8f51449ab26a4386cae0662a2676 1 parent c8ca83c
@jgraichen jgraichen authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 jquery.timeago.js
View
10 jquery.timeago.js
@@ -96,10 +96,12 @@
return new Date(s);
},
datetime: function(elem) {
- // jQuery's `is()` doesn't play well with HTML5 in IE
- var isTime = $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
- var iso8601 = isTime ? $(elem).attr("datetime") : $(elem).attr("title");
+ var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
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")) {
element.data("timeago", { datetime: $t.datetime(element) });
var text = $.trim(element.text());
- if (text.length > 0) {
+ if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
element.attr("title", text);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.