scala-js/scala-js-dom

Package org.scalajs.dom can't contain vanilla scala definitions

mseddon opened this issue · 0 comments

As revealed by #94.

package object dom extends js.Any, and as such it can't export the constructors for various javascript dictionaries.

As it stands, only MutationObserverInit and BlobPropertyBag have constructors, and with BlobPropertyBag only the type is being exported, so it's not being a problem. (though #117 would add a ClipboardEventInit constructor)

Currently my thoughts are either to:

  • Just accept that constructors can't go in the dom package, (keeping them in their defining package for now) with a note in the documentation.
  • Rename this package object to org.scalajs.dom.globals or similar, and create a new package that copies in these definitions along with the constructors.

Sadly @sjrd's implicit method trick can only work if dom were a singleton object, not a package.