Skip to content

Commit 11fd485

Browse files
committed
Review feedback from globalContext change
And add test
1 parent 57353c1 commit 11fd485

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

lib/helpers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Element? querySelector(String selectors) => document.querySelector(selectors);
5353

5454
bool isInstanceOfDomType(JSObject? o, String domType) {
5555
if (o == null) return false;
56-
final constructor = globalContext.getProperty(domType.toJS);
56+
final constructor = globalContext[domType];
5757
if (constructor == null) return false;
5858
return o.instanceof(constructor as JSFunction).toDart;
5959
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version: 0.1.5-wip
66
repository: https://github.com/dart-lang/web
77

88
environment:
9-
sdk: ">=3.2.0-75.0.dev <4.0.0"
9+
sdk: ">=3.2.0-157.0.dev <4.0.0"
1010

1111
dev_dependencies:
1212
args: ^2.4.0

test/helpers_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@TestOn('browser')
6+
library;
7+
8+
import 'package:test/test.dart';
9+
import 'package:web/helpers.dart';
10+
11+
void main() {
12+
test('isInstanceOfDomType', () {
13+
final div = document.createElement('div');
14+
15+
expect(isInstanceOfDomType(div, 'bob'), false);
16+
expect(isInstanceOfDomType(div, 'HTMLDivElement'), true);
17+
});
18+
}

0 commit comments

Comments
 (0)