-
Notifications
You must be signed in to change notification settings - Fork 12
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
Also allow using the modifier on SVG elements (types only) #235
Conversation
5d6f48f
to
19c3166
Compare
@@ -44,7 +44,7 @@ function compileStyles( | |||
} | |||
|
|||
export interface StyleModifierSignature { | |||
Element: HTMLElement; | |||
Element: HTMLElement | SVGElement; |
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.
@bwbuchanan proposed in #235 to fix the issue using ElementCSSInlineStyle
. Did you tested that?
Element: HTMLElement | SVGElement; | |
Element: ElementCSSInlineStyle; |
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.
Yes, that also works, I've committed 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.
Nope, actually it doesn't work, you can see the error in the CI. Ideas?
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.
This seems to be a limitation of the types provided by ember-modifier
. I reproduced in TypeScript playground: https://www.typescriptlang.org/play?#code/MYGwhgzhAEBCkFNoG8BQ0PWAewHYQBcAnAV2AOyIAoEQAuaAURAQFsFcCBKFAX1X6pQkGAGEAFgEsQAE2gIAHgQ4yY8CEjSYseQqXKUa9Ji3adRAZQsBJXCEm4EFggE8WPLdswQSABwTUtFwA3OiY-LxAA
I think we should rollback to your original solution HTMLElement | SVGElement
. Or do you now how to workaround it, @bwbuchanan?
19c3166
to
f42b4d3
Compare
This is what I used in import type { ModifierLike } from '@glint/template';
type StyleModifier = ModifierLike<{
Args: {
Positional: [styles: Record<string, string>] | [];
Named: Record<string, string>;
};
Element: ElementCSSInlineStyle;
}>;
const style: StyleModifier;
export default style; |
Does it work if using the type I think |
f42b4d3
to
c50384e
Compare
@bwbuchanan this seems to work, yes. But... is it really better? Why do you prefer/need |
I think that does not check if the interface is compatible with |
Yes, you are correct. I think that the type At the moment, this is basically the same as |
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.
Let's do the following:
- Land this with
HTMLElement | SVGElement | MathMLElement
. - Explore if we could fix types in
ember-modifier
to allowElementCSSInlineStyle
as a follow-up.
@boris-petrov: If you have capacities adding a test for MathMLElement
would be great. But I'm okay merging without that test.
@bwbuchanan: Thanks for your input. Highly appreciated!
@@ -44,7 +44,7 @@ function compileStyles( | |||
} | |||
|
|||
export interface StyleModifierSignature { | |||
Element: HTMLElement; | |||
Element: ElementCSSInlineStyle & Element; |
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.
Element: ElementCSSInlineStyle & Element; | |
Element: HTMLElement | SVGElement | MathMLElement; |
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 just looked more deeply into intersection types. ElementCSSInlineStyle & Element
seems to be a valid approach as well. @boris-petrov: I keep it up to you, which one we are going with.
c50384e
to
dab1561
Compare
I added a simple test for a
Obviously Otherwise I left it using |
Perhaps we can remove the |
I must admit that I'm not an expert on that topic. But for me it looks like a bug in upstream typing of the |
I think this is a glint bug, typing See: https://github.com/typed-ember/glint/blob/main/packages/template/-private/dsl/types.d.ts |
I suggest that |
Are you sure that those types are defined by glint? I would expect glint to pull them in from a standard package.
I prefer to use what allows all supported use cases for now. And make the types more strict in a follow-up as soon as we found a working solution. |
dab1561
to
0235bfc
Compare
Sorry for the delay. I left the |
Ah, no, |
ccd8517
to
fd89b6e
Compare
I also tried using |
I wasn't able to reproduce the issues with I would recommend keeping this one to SVG support only. We have a clear path forward for that case. I don't feel comfortable removing the Let's pull the test for |
fd89b6e
to
dd08232
Compare
Done. |
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 a lot!
Released as v4.3.0: https://github.com/jelhan/ember-style-modifier/releases/tag/v4.3.0 |
@bwbuchanan Did you reported that bug to Glint? |
I reported it upstream here: typed-ember/glint#758 |
Sorry, one more change. 😄
The
lint:types
task fails locally on my side (unrelated to this change). Not sure what I'm doing wrong but I hope here it will be fine.cc @jelhan