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
✨amp-timeago: Enable datetime to be set with amp-bind #18444
✨amp-timeago: Enable datetime to be set with amp-bind #18444
Conversation
mutatedAttributesCallback(mutations) { | ||
const datetime = mutations['datetime']; | ||
if (datetime !== undefined) { | ||
this.datetime_ = this.element.getAttribute('datetime'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this can just be datetime
cost per above, not need to read it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I've now updated that.
@@ -44,6 +44,8 @@ tags: { # <amp-timeago> | |||
value_regex: "\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d(:[0-5]\\d(\\.\\d+)?)?(Z|[+-][0-1][0-9]:[0-5][0-9])" | |||
} | |||
attrs: { name: "locale" } | |||
# <amp-bind> | |||
attrs: { name: "[datetime]" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth updating validator_time-ago.html and .out files as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some new validator test files for mutations - is this OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine.
const datetime = mutations['datetime']; | ||
if (datetime !== undefined) { | ||
this.datetime_ = this.element.getAttribute('datetime'); | ||
this.setFuzzyTimestampValue_(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the part that sets this.element.title
move to setFuzzyTimestampValue_
as well to keep the title up to date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in #18441, the title
attribute value is a bit difficult to resolve. I don't think there's anything we can do in setFuzzyTimestampValue_()
. The only solution I can think of is to also allow the title
attribute to be mutated with AMP bind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. sounds good to me.
fdf34af
to
aaac3d5
Compare
merged. Thanks Ed. |
* cl/215004714 Revision bump for ampproject#17162 * cl/215004778 Revision bump for ampproject#18415 * cl/215004829 Revision bump for ampproject#18439 * cl/215036706 Revision bump for ampproject#18444 * cl/215235362 Revision bump for ampproject#18438
* cl/215004714 Revision bump for ampproject#17162 * cl/215004778 Revision bump for ampproject#18415 * cl/215004829 Revision bump for ampproject#18439 * cl/215036706 Revision bump for ampproject#18444 * cl/215235362 Revision bump for ampproject#18438
Attempts to fix #18441 and allow the datetime attribute used in amp-timeago to be set with amp-bind.
The example file is also updated and now includes an amp-bind example.