-
Notifications
You must be signed in to change notification settings - Fork 1k
[localize-tools] Keep expressions in attribute values for transform mode #2692
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
Conversation
🦋 Changeset detectedLatest commit: a905a15 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
aomarks
left a comment
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.
Awesome! Just a small request for an extra test, and a question.
| ); | ||
| }); | ||
|
|
||
| test('html(msg(string)) with msg as attr value', () => { |
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.
Could you add one with a .bar property attribute, too? Same result, just for completeness.
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.
Done, and also added additional tests for having multiple attributes in a single template expression so as to test the logic for looking at both the head and the middle.
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.
Nice!
| ); | ||
| } | ||
| return template; | ||
| return newTemplate; |
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.
Oops! Do the tests in this PR fail if this is switched back to template? If not, is there a test we could add that would cover it?
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.
Upon taking a closer look now, it seems we never enter this code block if a translation does occur because then newTemplate would always be a ts.TemplateLiteral. The only time we enter this block is when we don't have to translate, i.e. generating original locale's version of the source, in which case newTemplate would not have changed from it's original assignment from template here:
| let newTemplate = template; |
So.. it was technically an oversight but of no consequence, hence none of our existing tests failed. For readability's sake I think keeping
newTemplate here still makes sense.
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.
sgtm
aomarks
left a comment
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.
Looks great
Fixes #2574
No longer subsume expressions into text if they follow a
=with the assumption being they are placed as a value of a html attribute, allowinglit-htmlto parse them properly.This PR also corrects an oversight from #2405 where we were returning the old
templaterather thannewTemplateif we had a simple string literal after applying translation.