Skip to content
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

How to add a new property to a img? #99

Closed
cyz1901 opened this issue Nov 5, 2023 · 6 comments
Closed

How to add a new property to a img? #99

cyz1901 opened this issue Nov 5, 2023 · 6 comments

Comments

@cyz1901
Copy link
Contributor

cyz1901 commented Nov 5, 2023

Hey @raquo i want to add crossOrigin(https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/crossOrigin) to img tag.

Do I just need to add this code in https://github.com/raquo/scala-dom-types/blob/04e66590f96216fe1e20036c4d9a32d59205526b/js/src/test/scala/com/thirdparty/defs/props/Props.scala#L713C2-L713C2 add code like

lazy val crossOrigin: Prop[String, String] = stringProp("crossOrigin")?

@raquo
Copy link
Owner

raquo commented Nov 5, 2023

Hi, if you just want to add it to your laminar project, you can just say:

val crossOrigin: HtmlProp[String] = htmlProp("crossOrigin", StringAsIsCodec)

(stringProp is not accessible to users, IIRC)

If you want to add it to SDT, you need to create a record for it in ReflectedHtmlAttrDefs.scala, with property name "crossOrigin" and attr name "crossorigin". If you're not up for that, I'll do it eventually.

MDN link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin

@cyz1901
Copy link
Contributor Author

cyz1901 commented Nov 6, 2023

Hi, if you just want to add it to your laminar project, you can just say:

val crossOrigin: HtmlProp[String] = htmlProp("crossOrigin", StringAsIsCodec)

(stringProp is not accessible to users, IIRC)

If you want to add it to SDT, you need to create a record for it in ReflectedHtmlAttrDefs.scala, with property name "crossOrigin" and attr name "crossorigin". If you're not up for that, I'll do it eventually.

MDN link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin

Hi @raquo

like this? #100

If appropriate, could you help approve this pr?

Or what else do I need to add....

Actually, I hope to use the newly added attr in Calico's DSL

Perhaps I should submit a PR to update Calico's dependencies scala-dom-types after making changes in this repository
Finally, use the latest Calico version in my project?

@raquo
Copy link
Owner

raquo commented Nov 6, 2023

Sure, please see my comments on that PR, it needs some small changes.

I am not sure what the Calico alternative to:

val crossOrigin: HtmlProp[String] = htmlProp("crossOrigin", StringAsIsCodec)

syntax is, it probably looks very similar, but it depends on their classes and method names.

@cyz1901
Copy link
Contributor Author

cyz1901 commented Nov 6, 2023

Sure, please see my comments on that PR, it needs some small changes.

I am not sure what the Calico alternative to:

val crossOrigin: HtmlProp[String] = htmlProp("crossOrigin", StringAsIsCodec)

syntax is, it probably looks very similar, but it depends on their classes and method names.

updated pr and need approve again

@raquo
Copy link
Owner

raquo commented Nov 7, 2023

Ok, merged, thanks. I can make a release later this week, I think. If you need this sooner, you really should figure out how to add custom attributes in your Calico project, it should be a simple one-liner. Just so that you're not blocked by the SDT release process.

@cyz1901
Copy link
Contributor Author

cyz1901 commented Nov 7, 2023

This is a good suggestion. Thank you for your help!

@cyz1901 cyz1901 closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants