universal_html 0.1.0 copy "universal_html: ^0.1.0" to clipboard
universal_html: ^0.1.0 copied to clipboard

outdated

Supports a subset of 'dart:html' in all platforms (browser, VM, and Flutter).

Overview #

This package is a pure Dart implemention of a subset of dart:html. The package works in all platforms (VM, Flutter, and browser).

Licensed under the MIT license.

The project welcomes new contributors:

Use cases #

  • Parsing/scraping HTML in the server/Flutter + browser.
  • Generating HTML in the server/Flutter + browser.

Features #

DOM APIs #

  • Node classes (Node, Element, CheckboxInputElement, etc.)
  • Printing (element.outerHtml, etc.)
  • Parsing (DomParser)
  • Queries (document.querySelector, node.matchesSelector)
  • Event handlers

Other APIs #

We have implemented various other APIs such as subsets ofwindow and navigator. Non-implemented APIs either throw UnimplementedError or fail silently when used in non-browser environment.

Correctness #

We test that the APIs behave identically to dart:html code running in Chrome. There are some failing tests.

For parsing, we use:

Getting started #

In pubspec.yaml:

name: example
dependencies:
  universal_html: ^0.1.0

Now you can replace usage of "dart:html" with "package:universal_html/html.dart":

import "package:universal_html/html.dart";

void main() {
  // Create a DOM tree
  final element = new Element.tag("h1")..appendText("Hello world!");

  // Print outer HTML
  print(element.outerHtml);
}
436
likes
30
pub points
99%
popularity

Publisher

verified publisherdint.dev

Supports a subset of 'dart:html' in all platforms (browser, VM, and Flutter).

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

charcode, csslib, html, meta

More

Packages that depend on universal_html