Files
sdk/tests/lib/html/js_interop_constructor_name/util.dart
T
Stephen Adams 5ff2459d88 Remove obsolete internal dart2js annotations
These annotations have all been replaced with @pragma('dart2js:xxx')
versions:

@ForceInline, @NoInline, @NoThrows, @NoSideEffects, @AssumeDynamic.

Change-Id: Ia4730670c6864ccbe0fa4120108c3c16ab887c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208863
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-04 23:27:18 +00:00

49 lines
1.1 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@JS()
library util;
import 'package:js/js.dart';
@JS()
external void eval(String code);
@JS()
external makeDiv(String text);
// Static error to name @JS class the same as a @Native class, so we use a
// namespace `Foo` to avoid conflicting with the native class.
@JS('Foo.HTMLDivElement')
class HTMLDivElement {
external String bar();
}
@pragma('dart2js:noInline')
@pragma('dart2js:assumeDynamic')
confuse(x) => x;
void setUpJS() {
eval(r"""
var Foo = {}
// A constructor function with the same name as a HTML element.
Foo.HTMLDivElement = function(a) {
this.a = a;
}
Foo.HTMLDivElement.prototype.bar = function() {
return this.a;
}
Foo.HTMLDivElement.prototype.toString = function() {
return "HTMLDivElement(" + this.a + ")";
}
self.makeDiv = function(text) {
return new Foo.HTMLDivElement(text);
}
""");
}