Files
sdk/tools/dom/templates/html/impl/impl_DOMException.darttemplate
T
Jacob Richman cf7ae2e0cb Support JS$ prefix for dart and fix bug where _operator_getter and the [] operator were used inconsistently. Would only impact future use cases where js APIs returned types not auto-proxied with dart:html.
Support typed JS interop classes that extend the behavior of  dart:html types in Dartium.

This theoretically enables supporting package:dom at the same time as dart:html as well as helping with
JavaScript libraries that monkey patch the dom.

Also support JS$ name prefix to resolve name conflicts with dart reserved words and with
dart:html libraries.
Cleanup addEventListener and friends so they are consistent with typed JS Interop and fix
bugs in the unlikely case where multiple functions have the same identity hash.
Add checks to make it easier to catch when allowInterop is accidentally omitted
when using the new typed JavaScript interop. You will now get an exception
any time you pass a Function to JS via the new typed interop without first
calling allowInterop.

BUG=
R=alanknight@google.com

Review URL: https://codereview.chromium.org/1583773003 .
2016-01-15 10:40:32 -08:00

93 lines
3.1 KiB
Plaintext

// Copyright (c) 2013, 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.
part of $LIBRARYNAME;
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
static const String INDEX_SIZE = 'IndexSizeError';
static const String HIERARCHY_REQUEST = 'HierarchyRequestError';
static const String WRONG_DOCUMENT = 'WrongDocumentError';
static const String INVALID_CHARACTER = 'InvalidCharacterError';
static const String NO_MODIFICATION_ALLOWED = 'NoModificationAllowedError';
static const String NOT_FOUND = 'NotFoundError';
static const String NOT_SUPPORTED = 'NotSupportedError';
static const String INVALID_STATE = 'InvalidStateError';
static const String SYNTAX = 'SyntaxError';
static const String INVALID_MODIFICATION = 'InvalidModificationError';
static const String NAMESPACE = 'NamespaceError';
static const String INVALID_ACCESS = 'InvalidAccessError';
static const String TYPE_MISMATCH = 'TypeMismatchError';
static const String SECURITY = 'SecurityError';
static const String NETWORK = 'NetworkError';
static const String ABORT = 'AbortError';
static const String URL_MISMATCH = 'URLMismatchError';
static const String QUOTA_EXCEEDED = 'QuotaExceededError';
static const String TIMEOUT = 'TimeoutError';
static const String INVALID_NODE_TYPE = 'InvalidNodeTypeError';
static const String DATA_CLONE = 'DataCloneError';
$if DART2JS
String get name {
var errorName = JS('String', '#.name', this);
// Although Safari nightly has updated the name to SecurityError, Safari 5
// and 6 still return SECURITY_ERR.
if (Device.isWebKit && errorName == 'SECURITY_ERR') return 'SecurityError';
// Chrome release still uses old string, remove this line when Chrome stable
// also prints out SyntaxError.
if (Device.isWebKit && errorName == 'SYNTAX_ERR') return 'SyntaxError';
return errorName;
}
$endif
$if JSINTEROP
String _name;
String _message;
// To suppress missing implicit constructor warnings.
factory DomException._() { throw new UnsupportedError("Not supported"); }
@Deprecated("Internal Use Only")
static DomException internalCreateDomException() {
return new DomException._internalWrap();
}
external factory DomException._internalWrap();
@Deprecated("Internal Use Only")
DomException.internal_() { }
@Deprecated("Internal Use Only")
DomException.jsInterop(String m) {
var name_index = m.indexOf(': ');
if (name_index < 0) {
_name = "";
_message = m;
} else {
_name = m.substring(0, name_index);
_message = m.substring(name_index + 1).trim();
}
}
@DomName('DOMException.message')
@DocsEditable()
String get message => _message;
@DomName('DOMException.name')
@DocsEditable()
String get name => _name;
@DomName('DOMException.toString')
@DocsEditable()
String toString() => "${_name}: $_message";
$else
$!MEMBERS
$endif
$if DART2JS
@DomName('DOMException.toString')
@DocsEditable()
String toString() => JS('String', 'String(#)', this);
$endif
}