mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:33:28 +00:00
Forward native static methods
We don't generate these. Rather than do that, this CL forwards to the actual JS method instead. This is the diff on the generated dart_sdk.js: 59732c59732 < return html$.LengthValue._fromDictionary_1(dictionary_1); --- > return dart.global.LengthValue.fromDictionary(dictionary_1); 59894c59894 < html$.MediaStreamTrack._getSources(dart.fn(value => { --- > dart.global.MediaStreamTrack.getSources(dart.fn(value => { 80232c80232 < html$.Notification._requestPermission(dart.fn(value => { --- > dart.global.Notification.requestPermission(dart.fn(value => { Change-Id: I9e857a808557e4702fb2b99aa518c25b49ff3db7 Reviewed-on: https://dart-review.googlesource.com/29020 Reviewed-by: Terry Lucas <terry@google.com> Commit-Queue: Vijay Menon <vsm@google.com>
This commit is contained in:
parent
4bda53d424
commit
e9d03b4120
|
@ -3078,6 +3078,17 @@ class CodeGenerator extends Object
|
|||
var member = _emitMemberName(name,
|
||||
isStatic: isStatic, type: type, element: accessor);
|
||||
|
||||
// A static native element should just forward directly to the
|
||||
// JS type's member.
|
||||
if (isStatic && _isExternal(element)) {
|
||||
var nativeName = getAnnotationName(classElem, isNativeAnnotation);
|
||||
if (nativeName != null) {
|
||||
var memberName = getAnnotationName(element, isJSName) ?? member;
|
||||
return js
|
||||
.call('#.#.#', [_callHelper('global'), nativeName, memberName]);
|
||||
}
|
||||
}
|
||||
|
||||
// For instance members, we add implicit-this.
|
||||
// For method tear-offs, we ensure it's a bound method.
|
||||
if (element is MethodElement &&
|
||||
|
|
19
tests/lib_2/html/notification_permission_test.dart
Normal file
19
tests/lib_2/html/notification_permission_test.dart
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html';
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:unittest/html_config.dart';
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
|
||||
main() async {
|
||||
useHtmlConfiguration();
|
||||
|
||||
test('Notification.requestPermission', () async {
|
||||
String permission = await Notification.requestPermission();
|
||||
expect(permission, isNotNull);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue