jquery-timeago
jquery-timeago copied to clipboard
function(elem) doesn't check for null values
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");
}
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?
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;
}