Skip to content

Conversation

@mysticfall
Copy link

  • Added WithBrowser trait, which you can mixin to test cases or other classes which needs DOM manipulation.
  • Separate Document and HTMLDocument classes, and change return types of some methods in Document for compatibility.
  • Rearrange and regroup attributes for legibility.

Previously, constructing a SVG document using DOMParser would result in a Document instance which has lot of non-working methods, as they're intended only for HTML. Both W3C DOM API and MDN reference document also distinguish those to types of interface, so I splitted them into separate classes.

And invoking getElementById() and casting the result into SVGElement was problematic, since the return type HTMLElement is not a parent type of the former.

I tried to group those attributes which roughly have related meaning. And I also added @deprecated annotation to some of the attributes of which MDN document clearly indicates as deprecated.

Still, there are lot of methods and attributes in HTMLDocument which are either outdated or IE specific, so we might need to extract them later into something like IEDocumentExtension.

@lihaoyi
Copy link
Contributor

lihaoyi commented Aug 11, 2014

Split for HTMLDocument/Document looks fine to me.

I don't see the point of WithBrowser. What's wrong with import dom.{document, window}?

Won't we need to change the type of dom.document to return a HTMLDocument for it to continue being correct?

@mysticfall
Copy link
Author

@lihaoyi It was just because I didn't know I could use import like that :) (blush)

And yes, it seems we should also change the type of dom.document to keep the API consistent.

How should I modify my commits to reflect above changes? Or could you just selectively merge the relevant commit?

@lihaoyi
Copy link
Contributor

lihaoyi commented Aug 11, 2014

I suggest you make your changes and squash them into a single commit. When you push the change back up to the branch (maybe with -f) the PR will automatically update, and it'll be easy to merge =)

* getElementById() returns Element, not HTMLElement * Reorder and regroup attributes for legibility * Deprecate non-working or outdated attributes
@lihaoyi
Copy link
Contributor

lihaoyi commented Aug 13, 2014

Build failed, merging anyway #yolo

lihaoyi added a commit that referenced this pull request Aug 13, 2014
Splitting HTMLDocument from Document, and other code clean ups.
@lihaoyi lihaoyi merged commit dfd070f into scala-js:master Aug 13, 2014
@mysticfall
Copy link
Author

Thanks! :)

Visbone pushed a commit to Visbone/scala-js-dom that referenced this pull request Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants