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
feat(compiler): support directive selectors with attributes containing $
#41567
feat(compiler): support directive selectors with attributes containing $
#41567
Conversation
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.
Thanks for submitting this PR @iRealNirmal.
Could you please add a unit test similar to https://github.com/angular/angular/blob/master/packages/compiler/test/selector/selector_spec.ts#L116-L127, which demonstrates this fix.
Also, can you modify the commit message slightly. It should not mention the issue number in the commit header, but instead have a Fixes
. Close
or Resolves
at the bottom of the commit body. Something like:
feat(compiler): Support directive selectors with attributes containing `$`
This commit adds support for `$` in when selecting attributes.
Resolves #41244.
08e7204
to
9e01ab1
Compare
Thanks @petebacondarwin. I have taken care for your both of comment. But I am not sure why test_aio_preview failed. Will you be able to provide any insight here ? |
Thanks @iRealNirmal - the second commit could have been a "fixup" commit. You can read more about this here: https://github.com/angular/angular/blob/master/docs/FIXUP_COMMITS.md. Also I made a mistake the first letter of the commit header should not be uppercase. Could you either change the second commit to a fixup, or just squash both commits into one? |
d8f3124
to
4b63c53
Compare
0a0a800
to
0ed65cb
Compare
$
@petebacondarwin let me know in case anything else needs to be done in this PR. |
0ed65cb
to
cf32005
Compare
@crisbeto - That seems like a perfectly reasonable error message for using an attribute incorrectly, no? Or am I missing something? If there is no such output on a directive/component, then the AOT compiler would complain before it got to runtime, no? |
It's possible that I'm missing some context as well, but wouldn't this also allow for any attribute containing |
I just double-checked it and we already allow |
Thanks for checking |
0503d35
to
17515b4
Compare
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.
Please make sure that the following tests pass:
it('should detect attr names with escaped $', () => {
let cssSelector = CssSelector.parse('[attrname\\$]')[0];
expect(cssSelector.attrs).toEqual(['attrname$', '']);
expect(cssSelector.toString()).toEqual('[attrname\\$]');
cssSelector = CssSelector.parse('[\\$attrname]')[0];
expect(cssSelector.attrs).toEqual(['$attrname', '']);
expect(cssSelector.toString()).toEqual('[\\$attrname]');
cssSelector = CssSelector.parse('[foo\\$bar]')[0];
expect(cssSelector.attrs).toEqual(['foo$bar', '']);
expect(cssSelector.toString()).toEqual('[foo\\$bar]');
});
it('should error on attr names with unescaped $', () => {
expect(() => CssSelector.parse('[attrname$]'))
.toThrowError(
'Error in attribute selector "attrname$". Unescaped "$" is not supported. Please escape with "\\$".');
expect(() => CssSelector.parse('[$attrname]'))
.toThrowError(
'Error in attribute selector "$attrname". Unescaped "$" is not supported. Please escape with "\\$".');
expect(() => CssSelector.parse('[foo$bar]'))
.toThrowError(
'Error in attribute selector "foo$bar". Unescaped "$" is not supported. Please escape with "\\$".');
expect(() => CssSelector.parse('[foo\\$bar$]'))
.toThrowError(
'Error in attribute selector "foo\\$bar$". Unescaped "$" is not supported. Please escape with "\\$".');
});
81081f2
to
4bd48d8
Compare
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.
Great! I restarted the failing jobs - they are most likely flakes.
Just one update to the tests are needed.
356b4a3
to
b39d5c0
Compare
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 work. Thanks @iRealNirmal
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.
LGTM, thanks for this PR 👍
I've added a comment to expand internal docs (add JSDoc for newly added functions), so that there is context to simplify future maintenance of that code.
2e92150
to
b61b580
Compare
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.
A couple of tiny fixes to the docs.
…g `$` This commit adds support for `$` in when selecting attributes. Resolves angular#41244. test(language-service): Add test to expose bug caused by source file change (angular#41500) This commit adds a test to expose the bug caused by source file change in between typecheck programs. PR Close angular#41500
b61b580
to
2c9ff71
Compare
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.
LGTM!
The requested changes have been made.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Added support for $ in attribtue type directive. This feaure is covered as the part of ticket #41244.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently directive selector isn't working if it has $ character in it.
Issue Number: 41244
What is the new behavior?
As per the feature requirement now directive attribute selector is support character $
Does this PR introduce a breaking change?
Other information