jquery-timeago icon indicating copy to clipboard operation
jquery-timeago copied to clipboard

function(elem) doesn't check for null values

Open logicminds opened this issue 12 years ago • 2 comments
trafficstars

The following code breaks when a null value is passed in. Surrounding with a conditional block will fix this.

isTime: function(elem) {
// jQuery's `is()` doesn't play well with HTML5 in IE
return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
} 

logicminds avatar Oct 03 '13 17:10 logicminds

Fair enough, but what scenario are you running into where a null value gets passed to this function? Are you using the isTime or datetime function directly outside of the timeago plugin?

rmm5t avatar Oct 03 '13 19:10 rmm5t

I am using the timeago function inside my own function that essentially populates DOM objects. I abbreviated my function below.

function setTimeago(stamp){
     value = jQuery.timeago(stamp);
      document.getElementById("someobjectid").innerHTML = value;

}

logicminds avatar Oct 03 '13 19:10 logicminds