New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add datetime attribute alternative following W3C recommendations #91
Conversation
sorry for confused, that is a typo of readme. Maybe you can pr for this. after 2.x.x, |
This is a PR^^ |
A small question btw.: Is there any difference when using |
I'll treat that as a "there is a difference, but if it works it doesn't matter" Thanks |
I means in v1.x.x, The I think there are no differences between querySelectorAll against getElementsByClassName when using |
@hustcc I figured. But I think having a data-timeago attribute as alternative is a good idea. |
ok~ compatible with jquery maybe will be perfact. if(node.dataset.timeago) return node.dataset.timeago; // js
if(node.data) return node.data['timeago']; //jq
if (node.getAttribute) return node.getAttribute(ATTR_DATETIME); // js
if(node.attr) return node.attr(ATTR_DATETIME); //jq |
@hustcc is it a joke? 😄 We should provide compatibility with standard, not with some library until it's a plugin for the library |
not jquery plugin, not jquery plugin, not jquery plugin. 😄😄😄 before the PR, we use it below: <time datetime='2016-11-09 12:12:12'></time> timeago.render(document.getElementsByTag('time'));
// or jq selector
timeago.render($(tag)); After be compatibility with standard by <time data-timeago='2016-11-09 12:12:12'></time> We can not select the timeago.render(document.getElementsByTag('time')); Can not be used with I think compatibility with W3C standard is OK, but we should keep the Pool english maybe can not express what I mean -_-!! |
@hustcc thx, I understand what you mean, but let me correct you a little. After PR you will still be able to query elements by document.querySelectorAll('[data-timeago]') and in jquery: $('[data-timeago]') |
But.. hm.. honestly I don't see the difference between: <time datetime='2016-11-09 12:12:12'></time>
// and
<time data-timeago='2016-11-09 12:12:12'></time> They both are queried the same way: document.getElementsByTag('time') |
The problem I see with this snippet, is that if jQuery is supported and the data-timeago attribute is not set the method will return an empty string without checking if the datetime attribute is set. Nonetheless I'd like to point out that @hutscc as owner of this repo has write access to my branch - allowing her to edit my PR without me |
😄 |
@hustcc I noticed, the dist folder isn't updated yet. I'd appreciate if you could rerun minifiers etc. |
done, include ro locale and this pr. |
Picky, I know.
In your README.md you mentioned the possible use of a
data-timeago
attribute instead of the "W3C-illegal" datetime attribute (see W3C Recommendation) which we couldn't actually use before this PR.This PR adds the possibility to use the
data-timeago
attribute for the automatic rendering while maintaining backwards compatibility.