scala-js / scala-js-dom

Statically typed DOM API for Scala.js
Other
315 stars 160 forks source link

Add `Image` facade and additional facades for `HTMLImageElement` #621 #725

Closed zetashift closed 1 year ago

zetashift commented 2 years ago

Another good first issue!

zetashift commented 1 year ago

Actually finding a name for ImageLoadingMode was the hardest part hahaha. I looked at the specs and it didn't have a name for it. MDN also feels very unofficial with the "hint" so I used mode just to get started. Policy sounds okay, but they also just drop that in a comment, the type itself doesn't really have a name...

I was also wondering if it should be Image and not HTMLImageLoadingMode :P. I don't have a real preference, hint could probably be the most familiar to people because MDN describes it like that.

armanbilge commented 1 year ago

Ha yeah I thought as much 😂

Looking at the existing enums we have, both "mode" and "policy" are common. So I think either is a fine choice. No "hint". https://github.com/scala-js/scala-js-dom/tree/main/dom/src/main/scala-3/org/scalajs/dom

Now it's just a philosophical question of what the difference between those is 🤔

zetashift commented 1 year ago

I guess "mode" sounds like it can only be certain cases, whereas policy sounds more like "something that just should be followed but might not be"?

Naming is hard :P

armanbilge commented 1 year ago

lol, well what about this? They seem to call it a "state" https://html.spec.whatwg.org/multipage/urls-and-fetching.html#lazy-loading-attributes

The other thing that's notable is that it's not specific to Image, seems that iframe uses it too. So I wonder if it should actually be shared by both 🤔

zetashift commented 1 year ago

Yuck, I don't find state fitting, but spec is spec...

Can rename to something like LoadingState

armanbilge commented 1 year ago

Ok ... coming back to this ... 😅

I think I'm in favor of LazyLoadingState. Since it's the "lazy loading attribute", and "Some attributes, called enumerated attributes, take on a finite set of states". So that seems like the specciest name.

zetashift commented 1 year ago

@armanbilge I renamed it to LazyLoadingState and changed the Longs to Doubles!