Unverified Commit e1645b15 authored by Kevin Moore's avatar Kevin Moore Committed by GitHub

[web] Move JS interop to extension types (#143274)

Now that we can bump the min SDK to latest.
parent 52f923c3
......@@ -33,11 +33,7 @@ external Document get document;
@JS()
external Window get window;
@JS('CSSStyleDeclaration')
@staticInterop
class CSSStyleDeclaration {}
extension CSSStyleDeclarationExtension on CSSStyleDeclaration {
extension type CSSStyleDeclaration._(JSObject _) implements JSObject {
external set backgroundColor(String value);
external String get backgroundColor;
external set border(String value);
......@@ -48,22 +44,14 @@ extension CSSStyleDeclarationExtension on CSSStyleDeclaration {
external String get width;
}
@JS('CSSStyleSheet')
@staticInterop
class CSSStyleSheet {}
extension CSSStyleSheetExtension on CSSStyleSheet {
extension type CSSStyleSheet._(JSObject _) implements JSObject {
external int insertRule(
String rule, [
int index,
]);
}
@JS('Document')
@staticInterop
class Document implements Node {}
extension DocumentExtension on Document {
extension type Document._(JSObject _) implements JSObject {
external Element createElement(
String localName, [
JSAny options,
......@@ -72,32 +60,18 @@ extension DocumentExtension on Document {
external HTMLHeadElement? get head;
}
@JS('DOMTokenList')
@staticInterop
class DOMTokenList {}
extension DOMTokenListExtension on DOMTokenList {
extension type DOMTokenList._(JSObject _) implements JSObject {
external void add(String tokens);
}
@JS('Element')
@staticInterop
class Element implements Node {}
extension ElementExtension on Element {
extension type Element._(JSObject _) implements Node, JSObject {
external DOMTokenList get classList;
external void append(JSAny nodes);
}
@JS('Event')
@staticInterop
class Event {}
@JS('EventTarget')
@staticInterop
class EventTarget {}
extension type Event._(JSObject _) implements JSObject {}
extension EventTargetExtension on EventTarget {
extension type EventTarget._(JSObject _) implements JSObject {
external void addEventListener(
String type,
EventListener? callback, [
......@@ -105,91 +79,52 @@ extension EventTargetExtension on EventTarget {
]);
}
@JS('HTMLElement')
@staticInterop
class HTMLElement implements Element {}
extension HTMLElementExtension on HTMLElement {
extension type HTMLElement._(JSObject _) implements Element, JSObject {
external String get innerText;
external set innerText(String value);
external CSSStyleDeclaration get style;
}
@JS('HTMLHeadElement')
@staticInterop
class HTMLHeadElement implements HTMLElement {}
@JS('HTMLStyleElement')
@staticInterop
class HTMLStyleElement implements HTMLElement {}
extension type HTMLHeadElement._(JSObject _) implements HTMLElement, JSObject {}
extension HTMLStyleElementExtension on HTMLStyleElement {
extension type HTMLStyleElement._(JSObject _) implements HTMLElement, JSObject {
external CSSStyleSheet? get sheet;
}
@JS('MediaQueryList')
@staticInterop
class MediaQueryList {}
extension MediaQueryListExtension on MediaQueryList {
extension type MediaQueryList._(JSObject _) implements EventTarget, JSObject {
external bool get matches;
}
@JS('MouseEvent')
@staticInterop
class MouseEvent {}
extension MouseEventExtension on MouseEvent {
extension type MouseEvent._(JSObject _) implements JSObject {
external num get offsetX;
external num get offsetY;
external int get button;
}
@JS('Navigator')
@staticInterop
class Navigator {}
extension NavigatorExtension on Navigator {
extension type Navigator._(JSObject _) implements JSObject {
external String get platform;
}
@JS('Node')
@staticInterop
class Node implements EventTarget {}
@JS('Range')
@staticInterop
class Range {}
extension type Node._(JSObject _) implements EventTarget, JSObject {}
extension RangeExtension on Range {
extension type Range._(JSObject _) implements JSObject {
external void selectNode(Node node);
}
@JS('Selection')
@staticInterop
class Selection {}
extension SelectionExtension on Selection {
extension type Selection._(JSObject _) implements JSObject {
external void addRange(Range range);
external void removeAllRanges();
}
@JS('Window')
@staticInterop
class Window {}
extension WindowExtension on Window {
extension type Window._(JSObject _) implements EventTarget, JSObject {
external Navigator get navigator;
external MediaQueryList matchMedia(String query);
external Selection? getSelection();
}
@JS('XMLHttpRequest')
@staticInterop
class XMLHttpRequest implements XMLHttpRequestEventTarget {
extension type XMLHttpRequest._(JSObject _)
implements XMLHttpRequestEventTarget, JSObject {
external factory XMLHttpRequest();
}
extension XMLHttpRequestExtension on XMLHttpRequest {
external void open(
String method,
String url, [
......@@ -208,6 +143,5 @@ extension XMLHttpRequestExtension on XMLHttpRequest {
external JSAny? get response;
}
@JS('XMLHttpRequestEventTarget')
@staticInterop
class XMLHttpRequestEventTarget implements EventTarget {}
extension type XMLHttpRequestEventTarget._(JSObject _)
implements EventTarget, JSObject {}
......@@ -3,7 +3,7 @@ description: A framework for writing Flutter applications
homepage: https://flutter.dev
environment:
sdk: '>=3.2.0-0 <4.0.0'
sdk: '>=3.3.0-0 <4.0.0'
dependencies:
# To update these, use "flutter update-packages --force-upgrade".
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment