Skip to content

Commit

Permalink
Add generated element constructors (#185)
Browse files Browse the repository at this point in the history
For every tag that the interface supports, emits a Dart
constructor that can be used to create an element of that tag
using either createElement or createElementNS. Adds a dependency
to @webref/elements to fetch the element data.

Note that not every element interface has a tag associated with it.

Adds a test and modifies existing helper messages to
point to the new constructors instead.

Also deprecates createAudioElement.
  • Loading branch information
srujzs authored Feb 29, 2024
1 parent 5e5adc8 commit 641a8df
Show file tree
Hide file tree
Showing 20 changed files with 1,275 additions and 136 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- Include MDN API documentation as class and member dartdoc comments. Docs
sourced from the [MDN Web Docs][] project; attributions and copyright
licensing by Mozilla Contributors is licensed under [CC-BY-SA 2.5][].
- Add a constructor for each Element tag onto their respective Element
interfaces.
- Remove `external` Element constructors that would result in a runtime error.
- Deprecate `createAudioElement` in favor of the `HTMLAudioElement` constructor.

[MDN Web Docs]: https://developer.mozilla.org/en-US/docs/Web
[CC-BY-SA 2.5]: https://creativecommons.org/licenses/by-sa/2.5/
Expand Down
15 changes: 15 additions & 0 deletions lib/src/dom/css_masking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,34 @@ library;

import 'dart:js_interop';

import 'dom.dart';
import 'svg.dart';

/// The **`SVGClipPathElement`** interface provides access to the properties of
/// elements, as well as methods to manipulate them.
extension type SVGClipPathElement._(JSObject _)
implements SVGElement, JSObject {
/// Creates an [SVGClipPathElement] using the tag 'clipPath'.
SVGClipPathElement()
: _ = document.createElementNS(
'http://www.w3.org/2000/svg',
'clipPath',
);

external SVGAnimatedEnumeration get clipPathUnits;
external SVGAnimatedTransformList get transform;
}

/// The **`SVGMaskElement`** interface provides access to the properties of
/// elements, as well as methods to manipulate them.
extension type SVGMaskElement._(JSObject _) implements SVGElement, JSObject {
/// Creates an [SVGMaskElement] using the tag 'mask'.
SVGMaskElement()
: _ = document.createElementNS(
'http://www.w3.org/2000/svg',
'mask',
);

external SVGAnimatedEnumeration get maskUnits;
external SVGAnimatedEnumeration get maskContentUnits;
external SVGAnimatedLength get x;
Expand Down
Loading

0 comments on commit 641a8df

Please sign in to comment.