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

documentation #342

Open
woutervanwijk opened this issue Feb 17, 2025 · 1 comment
Open

documentation #342

woutervanwijk opened this issue Feb 17, 2025 · 1 comment

Comments

@woutervanwijk
Copy link

woutervanwijk commented Feb 17, 2025

The documentation on migrating from dart:html is not really clear on https://dart.dev/interop/js-interop/package-web

For example, I looked to replace AnchorElement(). It's not clear that you can just put HTML in front of the name and it works: HTMLAnchorElement(). The documentation talks about " HTMLElement became HtmlElement", which is not a helpful example, but not about these basic things.

Also, something like replacing an import like 'package:html/parser.dart' is not clear. Where is the parser?

I'm also wondering if conditional imports like this still work with dart:web

import 'package:fiper/utils/html_functions_empty.dart'
    if (dart.library.html) 'package:fiper/utils/html_functions.dart' as html;

The migration document is really not clear on these things

@srujzs
Copy link
Contributor

srujzs commented Feb 18, 2025

It's not clear that you can just put HTML in front of the name and it works: HTMLAnchorElement()

Well, the strategy doesn't always work. :) There is a dart fix for this you can try applying: https://dart.dev/interop/js-interop/package-web#renames. We hope to continue to add more. In the same section, there is some information on how to find the corresponding type in package:web if the name is different (look and compare the @Native and @JS annotations), but noted that it might not be obvious.

Also, something like replacing an import like 'package:html/parser.dart' is not clear. Where is the parser?

I don't understand. package:html is a separate thing entirely and is intended for parsing HTML. dart:html and package:web contain bindings to interact with the DOM and browser APIs.

I'm also wondering if conditional imports like this still work with dart:web

https://dart.dev/interop/js-interop/package-web#conditional-imports has some basic information that tells you to use dart.library.js_interop to differentiate between web and the VM. What specifically are you aiming to do with conditional imports?

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