Update getClientRects, removed xtab, removed bogus entry in dom.json,

expose ServiceWorker, removed query and queryAll from in dart:html,
added constructor to MessageChannel and removed getCssCanvasContext.

Fixed all tests using query and queryAll.

Fixes https://github.com/dart-lang/sdk/issues/25664
Fixes https://github.com/dart-lang/sdk/issues/26349
Fixes https://github.com/dart-lang/sdk/issues/32323
Fixes https://github.com/dart-lang/sdk/issues/32659
Fixes https://github.com/dart-lang/sdk/issues/32675

R=kevmoo@google.com

Change-Id: I687471e80b8fe9c7040673113f424dbaab7c64d4
Reviewed-on: https://dart-review.googlesource.com/48381
Commit-Queue: Terry Lucas <terry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
This commit is contained in:
Terry Lucas 2018-03-27 20:45:33 +00:00 committed by commit-bot@chromium.org
parent f9e12f1116
commit bc75856e54
59 changed files with 446 additions and 649 deletions

View file

@ -12377,25 +12377,6 @@ class Document extends Node {
ElementList<T> querySelectorAll<T extends Element>(String selectors) =>
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('Document.querySelector')
Element query(String relativeSelectors) => querySelector(relativeSelectors);
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('Document.querySelectorAll')
ElementList<T> queryAll<T extends Element>(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
/// Checks if [registerElement] is supported on the current platform.
bool get supportsRegisterElement {
return JS('bool', '("registerElement" in #)', this);
@ -12560,26 +12541,6 @@ class DocumentFragment extends Node
validator: validator, treeSanitizer: treeSanitizer));
}
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('DocumentFragment.querySelector')
Element query(String relativeSelectors) {
return querySelector(relativeSelectors);
}
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('DocumentFragment.querySelectorAll')
ElementList<T> queryAll<T extends Element>(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
// To suppress missing implicit constructor warnings.
factory DocumentFragment._() {
throw new UnsupportedError("Not supported");
@ -15707,25 +15668,6 @@ class Element extends Node
ElementList<T> querySelectorAll<T extends Element>(String selectors) =>
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@DomName('Element.querySelector')
@Experimental()
Element query(String relativeSelectors) => querySelector(relativeSelectors);
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@DomName('Element.querySelectorAll')
@Experimental()
ElementList<T> queryAll<T extends Element>(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
/**
* The set of CSS classes applied to this element.
*
@ -15888,8 +15830,6 @@ class Element extends Node
@DomName('Element.getClientRects')
@DocsEditable()
@Returns('DomRectList|Null')
@Creates('DomRectList')
List<Rectangle> getClientRects() {
var value = _getClientRects();
@ -15960,31 +15900,6 @@ class Element extends Node
*/
void attributeChanged(String name, String oldValue, String newValue) {}
// Hooks to support custom WebComponents.
@Creates('Null') // Set from Dart code; does not instantiate a native type.
Element _xtag;
/**
* Experimental support for [web components][wc]. This field stores a
* reference to the component implementation. It was inspired by Mozilla's
* [x-tags][] project. Please note: in the future it may be possible to
* `extend Element` from your class, in which case this field will be
* deprecated.
*
* If xtag has not been set, it will simply return `this` [Element].
*
* [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
* [x-tags]: http://x-tags.org/
*/
// Note: return type is `dynamic` for convenience to suppress warnings when
// members of the component are used. The actual type is a subtype of Element.
get xtag => _xtag != null ? _xtag : this;
set xtag(Element value) {
_xtag = value;
}
@DomName('Element.localName')
@DocsEditable()
@Returns('String')
@ -17669,8 +17584,8 @@ class Element extends Node
*/
@DomName('Element.getClientRects')
@DocsEditable()
@Returns('DomRectList|Null')
@Creates('DomRectList')
@Returns('DomRectList|Null')
List<Rectangle> _getClientRects() native;
/**
@ -19287,8 +19202,8 @@ class ExtendableMessageEvent extends ExtendableEvent {
@DomName('ExtendableMessageEvent.source')
@DocsEditable()
@Experimental() // untriaged
@Creates('Client|_ServiceWorker|MessagePort')
@Returns('Client|_ServiceWorker|MessagePort|Null')
@Creates('Client|ServiceWorker|MessagePort')
@Returns('Client|ServiceWorker|MessagePort|Null')
final Object source;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@ -22021,48 +21936,6 @@ class HtmlDocument extends Document {
return _elementFromPoint(x, y);
}
/**
* Checks if the getCssCanvasContext API is supported on the current platform.
*
* See also:
*
* * [getCssCanvasContext]
*/
static bool get supportsCssCanvasContext =>
JS('bool', '!!(document.getCSSCanvasContext)');
/**
* Gets a CanvasRenderingContext which can be used as the CSS background of an
* element.
*
* CSS:
*
* background: -webkit-canvas(backgroundCanvas)
*
* Generate the canvas:
*
* var context = document.getCssCanvasContext('2d', 'backgroundCanvas',
* 100, 100);
* context.fillStyle = 'red';
* context.fillRect(0, 0, 100, 100);
*
* See also:
*
* * [supportsCssCanvasContext]
* * [CanvasElement.getContext]
*/
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental()
@DomName('Document.getCSSCanvasContext')
CanvasRenderingContext getCssCanvasContext(
String contextId, String name, int width, int height) {
if (HtmlDocument.supportsCssCanvasContext)
return JS('CanvasRenderingContext', '#.getCSSCanvasContext(#, #, #, #)',
this, contextId, name, width, height);
throw new UnsupportedError("Not supported");
}
@DomName('Document.head')
HeadElement get head => _head;
@ -26921,6 +26794,14 @@ class MessageChannel extends Interceptor {
throw new UnsupportedError("Not supported");
}
@DomName('MessageChannel.MessageChannel')
@DocsEditable()
factory MessageChannel() {
return MessageChannel._create_1();
}
static MessageChannel _create_1() =>
JS('MessageChannel', 'new MessageChannel()');
@DomName('MessageChannel.port1')
@DocsEditable()
final MessagePort port1;
@ -33674,8 +33555,6 @@ class Range extends Interceptor {
@DomName('Range.getClientRects')
@DocsEditable()
@Returns('DomRectList|Null')
@Creates('DomRectList')
List<Rectangle> getClientRects() {
var value = _getClientRects();
@ -35795,6 +35674,47 @@ class SensorErrorEvent extends Event {
// 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.
@DocsEditable()
@DomName('ServiceWorker')
@Experimental() // untriaged
@Native("ServiceWorker")
class ServiceWorker extends EventTarget implements AbstractWorker {
// To suppress missing implicit constructor warnings.
factory ServiceWorker._() {
throw new UnsupportedError("Not supported");
}
@DomName('ServiceWorker.errorEvent')
@DocsEditable()
@Experimental() // untriaged
static const EventStreamProvider<Event> errorEvent =
const EventStreamProvider<Event>('error');
@JSName('scriptURL')
@DomName('ServiceWorker.scriptURL')
@DocsEditable()
@Experimental() // untriaged
final String scriptUrl;
@DomName('ServiceWorker.state')
@DocsEditable()
@Experimental() // untriaged
final String state;
@DomName('ServiceWorker.postMessage')
@DocsEditable()
@Experimental() // untriaged
void postMessage(Object message, [List<Object> transfer]) native;
@DomName('ServiceWorker.onerror')
@DocsEditable()
@Experimental() // untriaged
Stream<Event> get onError => errorEvent.forTarget(this);
}
// Copyright (c) 2012, 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.
@DocsEditable()
@DomName('ServiceWorkerContainer')
@Experimental() // untriaged
@ -35814,7 +35734,7 @@ class ServiceWorkerContainer extends EventTarget {
@DomName('ServiceWorkerContainer.controller')
@DocsEditable()
@Experimental() // untriaged
final _ServiceWorker controller;
final ServiceWorker controller;
@DomName('ServiceWorkerContainer.ready')
@DocsEditable()
@ -35960,7 +35880,7 @@ class ServiceWorkerRegistration extends EventTarget {
@DomName('ServiceWorkerRegistration.active')
@DocsEditable()
@Experimental() // untriaged
final _ServiceWorker active;
final ServiceWorker active;
@DomName('ServiceWorkerRegistration.backgroundFetch')
@DocsEditable()
@ -35970,7 +35890,7 @@ class ServiceWorkerRegistration extends EventTarget {
@DomName('ServiceWorkerRegistration.installing')
@DocsEditable()
@Experimental() // untriaged
final _ServiceWorker installing;
final ServiceWorker installing;
@DomName('ServiceWorkerRegistration.navigationPreload')
@DocsEditable()
@ -36000,7 +35920,7 @@ class ServiceWorkerRegistration extends EventTarget {
@DomName('ServiceWorkerRegistration.waiting')
@DocsEditable()
@Experimental() // untriaged
final _ServiceWorker waiting;
final ServiceWorker waiting;
@DomName('ServiceWorkerRegistration.getNotifications')
@DocsEditable()
@ -45910,21 +45830,6 @@ abstract class _Response extends Body {
// 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.
@DocsEditable()
@DomName('ServiceWorker')
@Experimental() // untriaged
@Native("ServiceWorker")
abstract class _ServiceWorker extends EventTarget implements AbstractWorker {
// To suppress missing implicit constructor warnings.
factory _ServiceWorker._() {
throw new UnsupportedError("Not supported");
}
}
// Copyright (c) 2012, 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.
@DocsEditable()
@DomName('SpeechRecognitionResultList')
// https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#speechrecognitionresultlist
@ -51524,22 +51429,6 @@ void Function(T1, T2) _wrapBinaryZone<T1, T2>(void Function(T1, T2) callback) {
return Zone.current.bindBinaryCallbackGuarded(callback);
}
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
Element query(String relativeSelectors) => document.query(relativeSelectors);
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
ElementList<Element> queryAll(String relativeSelectors) =>
document.queryAll(relativeSelectors);
/**
* Finds the first descendant element of this document that matches the
* specified group of selectors.

View file

@ -70,17 +70,39 @@ Language/Types/Interface_Types/subtype_t27: Skip # Times out or crashes. Issue 2
Language/Types/Interface_Types/subtype_t28: Pass, Fail, Crash # Stack overflow. Issue 25282
Language/Types/Interface_Types/subtype_t30: Fail # Issue 14654
Language/Types/Type_Void/syntax_t08: MissingCompileTimeError
LayoutTests/fast/borders/border-color-visited_t01: RuntimeError # See issue 143
LayoutTests/fast/canvas/fillText-shadow_t01: RuntimeError # See issue 143
LayoutTests/fast/css/content/content-quotes-01_t01: Pass, RuntimeError
LayoutTests/fast/css/font-face-cache-bug_t01: Pass, RuntimeError
LayoutTests/fast/css/fontfaceset-loadingdone_t01: Pass, RuntimeError
LayoutTests/fast/css/misplaced-charset_t01: RuntimeError # See issue 143
LayoutTests/fast/css/pseudo-empty-dynamic-empty_t01: RuntimeError # See issue 143
LayoutTests/fast/css/remove-class-name_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/HTMLLinkElement/link-onload-stylesheet-with-import_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/dom/HTMLTableElement/createCaption_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/HTMLTableElement/early-acid3-66-excerpt_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/HTMLTableRowElement/insertCell_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/Range/create-contextual-fragment-script-unmark-already-started_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/clone-node-style_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/css-innerHTML_t01: SkipByDesign # Test is incorrect.
LayoutTests/fast/dom/icon-url-change_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/icon-url-list_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/mutation-event-remove-inserted-node_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/dom/shadow/event-path-not-in-document_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/dom/shared-inline-style-after-node-removal_t01: RuntimeError # See issue 143
LayoutTests/fast/dom/subtree-modified-attributes_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/events/form-onchange_t01: RuntimeError # See issue 143
LayoutTests/fast/events/onerror-bubbling_t01: RuntimeError # See issue 143
LayoutTests/fast/files/file-reader-done-reading-abort_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/forms/autofocus-attribute_t01: RuntimeError # See issue 143
LayoutTests/fast/forms/autofocus-opera-004_t01: RuntimeError # See issue 143
LayoutTests/fast/forms/autofocus-opera-005_t01: RuntimeError # See issue 143
LayoutTests/fast/forms/autofocus-opera-008_t01: RuntimeError # See issue 143
LayoutTests/fast/forms/input-implicit-length-limit_t01: SkipByDesign # Test is not about Dart, but about a DOM-only webkit bug that has been fixed.
LayoutTests/fast/forms/interactive-validation-attach-assertion_t01: RuntimeError # See issue 143
LayoutTests/fast/forms/search-popup-crasher_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/forms/select-namedItem_t01: RuntimeError # See issue 143
LayoutTests/fast/forms/select-reset-multiple-selections-4-single-selection_t01: RuntimeError # See issue 143
LayoutTests/fast/loader/loadInProgress_t01: Skip # Issue 23466
LayoutTests/fast/loader/stateobjects/replacestate-in-onunload_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/media/mq-parsing_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
@ -110,6 +132,8 @@ LayoutTests/fast/transforms/scrollIntoView-transformed_t01: Skip # https://githu
LayoutTests/fast/writing-mode/percentage-margins-absolute_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/xmlhttprequest/xmlhttprequest-responsetype-abort_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/xpath/4XPath/Core/test_core_functions_t02: Skip # https://github.com/dart-lang/sdk/issues/28873
LayoutTests/fast/xpath/4XPath/Core/test_location_path_t01: RuntimeError # See issue 143
LayoutTests/fast/xpath/4XPath/Core/test_step_t01: RuntimeError # See issue 143
LayoutTests/fast/xpath/ambiguous-operators_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
LibTest/async/Future/Future.delayed_A01_t02: Pass, Fail # Issue 15524
LibTest/collection/LinkedHashSet/LinkedHashSet.from_A03_t01: RuntimeError # Please triage this failure.
@ -148,6 +172,8 @@ LibTest/core/int/operator_remainder_A01_t01: RuntimeError, OK # Requires bigints
LibTest/core/int/operator_right_shift_A01_t01: RuntimeError, OK # Expects negative result from bit-operation.
LibTest/core/int/toDouble_A01_t01: RuntimeError, OK # co19 issue 200
LibTest/html/Element/addEventListener_A01_t04: Skip # https://github.com/dart-lang/sdk/issues/28873
LibTest/html/Element/queryAll_A01_t01: RuntimeError # See issue 143
LibTest/html/Element/query_A01_t01: RuntimeError # See issue 143
LibTest/html/HttpRequest/responseType_A01_t03: CompileTimeError # co19-roll r706: Please triage this failure
LibTest/html/IFrameElement/addEventListener_A01_t04: Skip # https://github.com/dart-lang/sdk/issues/28873
LibTest/html/IFrameElement/enteredView_A01_t01: CompileTimeError # co19-roll r706: Please triage this failure
@ -276,10 +302,22 @@ LibTest/typed_data/Uint8List/Uint8List_A02_t01: Fail # co19-roll r576: Please tr
Utils/tests/Expect/identical_A01_t01: Fail # co19-roll r546: Please triage this failure
WebPlatformTest/Utils/test/asyncTestFail_t02: Skip # https://github.com/dart-lang/sdk/issues/28873
WebPlatformTest/Utils/test/testFail_t01: RuntimeError # co19-roll r722: Please triage this failure.
WebPlatformTest/custom-elements/instantiating/isAttribute_A01_t01: RuntimeError # See issue 143
WebPlatformTest/custom-elements/instantiating/isAttribute_A01_t02: RuntimeError # See issue 143
WebPlatformTest/custom-elements/instantiating/isAttribute_A02_t01: RuntimeError # See issue 143
WebPlatformTest/custom-elements/instantiating/isAttribute_A03_t01: RuntimeError # See issue 143
WebPlatformTest/custom-elements/instantiating/localName_A01_t01: RuntimeError # See issue 143
WebPlatformTest/dom/EventTarget/dispatchEvent_A02_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
WebPlatformTest/dom/nodes/DOMImplementation-createHTMLDocument_t01: CompileTimeError # co19-roll r722: Please triage this failure.
WebPlatformTest/dom/nodes/Document-createElement_t01: CompileTimeError # co19-roll r722: Please triage this failure.
WebPlatformTest/dom/nodes/Element-childElementCount-nochild_t01: CompileTimeError # co19-roll r722: Please triage this failure.
WebPlatformTest/html/dom/elements/global-attributes/classlist-nonstring_t01: RuntimeError # See issue 143
WebPlatformTest/html/semantics/forms/the-textarea-element/textarea-type_t01: RuntimeError # See issue 143
WebPlatformTest/html/semantics/tabular-data/the-table-element/insertRow-method_t01: RuntimeError # See issue 143
WebPlatformTest/html/semantics/tabular-data/the-table-element/insertRow-method_t02: RuntimeError # See issue 143
WebPlatformTest/html/semantics/tabular-data/the-table-element/tBodies_t01: RuntimeError # See issue 143
WebPlatformTest/html/semantics/text-level-semantics/the-a-element/a.text-getter_t01: RuntimeError # See issue 143
WebPlatformTest/html/semantics/text-level-semantics/the-a-element/a.text-setter_t01: RuntimeError # See issue 143
WebPlatformTest/webstorage/event_local_storageeventinit_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
WebPlatformTest/webstorage/storage_local_setitem_quotaexceedederr_t01: Skip # Times out. Please triage this failure.
WebPlatformTest/webstorage/storage_session_setitem_quotaexceedederr_t01: Skip # Times out. Please triage this failure

View file

@ -115,13 +115,13 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.documentElement.children.add(listElement);
var elements = document.queryAll('li');
var elements = document.querySelectorAll('li');
expect(elements.style.backgroundColor, equals('red'));
expect(elements.style.borderLeftWidth, equals('10px'));
elements = document.queryAll('.baz');
elements = document.querySelectorAll('.baz');
expect(elements.style.backgroundColor, equals('black'));
expect(elements.style.borderLeftWidth, equals(''));
elements = document.queryAll('.bar');
elements = document.querySelectorAll('.bar');
expect(elements.style.backgroundColor, equals('red'));
});
@ -135,25 +135,25 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.documentElement.children.add(listElement);
var elements = document.queryAll('li');
var elements = document.querySelectorAll('li');
elements.style.backgroundColor = 'green';
expect(elements.style.backgroundColor, equals('green'));
expect(elements.style.borderLeftWidth, equals('10px'));
elements = document.queryAll('.baz');
elements = document.querySelectorAll('.baz');
expect(elements.style.backgroundColor, equals('green'));
elements.style.backgroundColor = 'yellow';
expect(elements.style.backgroundColor, equals('yellow'));
expect(elements.style.borderLeftWidth, equals(''));
elements = document.queryAll('.bar');
elements = document.querySelectorAll('.bar');
expect(elements.style.backgroundColor, equals('green'));
elements = document.queryAll('#wat');
elements = document.querySelectorAll('#wat');
expect(elements.style.backgroundColor, equals('yellow'));
elements.style.borderLeftWidth = '18px';
expect(elements.style.borderLeftWidth, equals('18px'));
elements = document.queryAll('li');
elements = document.querySelectorAll('li');
expect(elements.style.borderLeftWidth, equals('10px'));
});

View file

@ -36,12 +36,12 @@ class C extends HtmlElement {
return;
}
var t = div.query('#t');
var v = div.query('#v');
var w = div.query('#w');
var t = div.querySelector('#t');
var v = div.querySelector('#v');
var w = div.querySelector('#w');
expect(query('x-b:not(:unresolved)'), this);
expect(queryAll(':unresolved'), [v, w]);
expect(querySelector('x-b:not(:unresolved)'), this);
expect(querySelectorAll(':unresolved'), [v, w]);
// As per:
// http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-parsing
@ -94,7 +94,7 @@ main() {
upgradeCustomElements(div);
expect(C.createdInvocations, 2);
expect(div.query('#w') is B, isTrue);
expect(div.querySelector('#w') is B, isTrue);
});
test('nesting of constructors', NestedElement.test);

View file

@ -139,7 +139,7 @@ main() {
treeSanitizer: new NullTreeSanitizer());
upgradeCustomElements(element);
document.body.nodes.add(element);
var queried = query(tag);
var queried = querySelector(tag);
expect(queried, isNotNull);
expect(queried is CustomType, isTrue);
@ -154,7 +154,7 @@ main() {
treeSanitizer: new NullTreeSanitizer());
upgradeCustomElements(element);
document.body.nodes.add(element);
var queried = query('#someid');
var queried = querySelector('#someid');
expect(queried, isNotNull);
expect(queried is CustomType, isTrue);

View file

@ -16,10 +16,10 @@ main() {
var element = new Element.tag('x-basic1')..id = 'basic1';
document.body.nodes.add(element);
var queryById = query('#basic1');
var queryById = querySelector('#basic1');
expect(queryById, equals(element));
var queryByTag = queryAll('x-basic1');
var queryByTag = querySelectorAll('x-basic1');
expect(queryByTag.length, equals(1));
expect(queryByTag[0], equals(element));
});
@ -30,10 +30,10 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.body.nodes.add(element);
var queryById = query('#basic2');
var queryById = querySelector('#basic2');
expect(queryById is Element, isTrue);
var queryByTag = queryAll('x-basic2');
var queryByTag = querySelectorAll('x-basic2');
expect(queryByTag.length, equals(1));
expect(queryByTag[0], equals(queryById));
});
@ -44,7 +44,7 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.body.nodes.add(element);
var queryById = query('#basic3');
var queryById = querySelector('#basic3');
expect(queryById is DivElement, isTrue);
});
}

View file

@ -29,7 +29,7 @@ main() {
expect(sessionStorage, equals(window.sessionStorage));
});
test('unknown', () {
var test = document.query('#test');
var test = document.querySelector('#test');
expect(element, equals(test));
});
}

View file

@ -40,22 +40,22 @@ main() {
test('is', () {
expect(() {
var list = document.query('#browsers');
var list = document.querySelector('#browsers');
expect(list, isDataListElement);
}, expectation);
});
test('list', () {
expect(() {
var list = document.query('#browsers');
var input = document.query('#input');
var list = document.querySelector('#browsers');
var input = document.querySelector('#input');
expect(input.list, list);
}, expectation);
});
test('options', () {
expect(() {
var options = document.query('#browsers').options;
var options = document.querySelector('#browsers').options;
expect(options.length, 5);
}, expectation);
});

View file

@ -36,7 +36,7 @@ main() {
</ResultSet>''',
'text/xml');
var rs = doc.query('ResultSet');
var rs = doc.querySelector('ResultSet');
expect(rs, isNotNull);
});
@ -54,7 +54,7 @@ main() {
expect(doc.adoptNode(div), div);
expect(div.ownerDocument, doc);
doc.body.nodes.add(div);
expect(doc.query('#foo').text, 'bar');
expect(doc.querySelector('#foo').text, 'bar');
});
test('importNode', () {
@ -64,7 +64,7 @@ main() {
expect(div2, isNot(equals(div)));
expect(div2.ownerDocument, doc);
doc.body.nodes.add(div2);
expect(doc.query('#foo').text, 'bar');
expect(doc.querySelector('#foo').text, 'bar');
});
test('typeTest1', () {

View file

@ -181,7 +181,8 @@ main() {
test('query searches the fragment', () {
var fragment = new DocumentFragment.html(
"<div class='foo'><a>foo</a><b>bar</b></div>");
expect(fragment.query(".foo a").tagName, "A");
expect(_nodeStrings(fragment.queryAll(".foo *")), equals(["A", "B"]));
expect(fragment.querySelector(".foo a").tagName, "A");
expect(
_nodeStrings(fragment.querySelectorAll(".foo *")), equals(["A", "B"]));
});
}

View file

@ -283,7 +283,7 @@ main() {
test('listClasses=', () {
var elements = listElementSetup();
elements.classes = ['foo', 'qux'];
elements = document.queryAll('li');
elements = document.querySelectorAll('li');
for (Element e in elements) {
expect(e.classes, orderedEquals(['foo', 'qux']));
expect(extractClasses(e), orderedEquals(['foo', 'qux']));

View file

@ -46,7 +46,7 @@ main() {
setUp(initDiv);
test('contentEdge.height', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.contentEdge.height, 10);
expect(all1[0].getComputedStyle().getPropertyValue('height'), '10px');
@ -72,7 +72,7 @@ main() {
});
test('contentEdge.height with border-box', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.contentEdge.height, 2);
div.style.padding = '20pc';
@ -82,7 +82,7 @@ main() {
});
test('contentEdge.width', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.contentEdge.width, 11);
expect(all1[0].getComputedStyle().getPropertyValue('width'), '11px');
@ -105,7 +105,7 @@ main() {
});
test('contentEdge.width with border-box', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.contentEdge.width, 3);
div.style.padding = '20pc';
@ -115,7 +115,7 @@ main() {
});
test('paddingEdge.height', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.paddingEdge.height, 18);
all1[0].style.visibility = 'hidden';
expect(all1.paddingEdge.height, 18);
@ -130,7 +130,7 @@ main() {
});
test('paddingEdge.height with border-box', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.paddingEdge.height, 10);
div.style.padding = '20pc';
@ -140,7 +140,7 @@ main() {
});
test('paddingEdge.width', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.paddingEdge.width, 19);
all1[0].style.visibility = 'hidden';
expect(all1.paddingEdge.width, 19);
@ -156,7 +156,7 @@ main() {
});
test('paddingEdge.width with border-box', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.paddingEdge.width, 11);
div.style.padding = '20pc';
@ -166,7 +166,7 @@ main() {
});
test('borderEdge.height and marginEdge.height', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(div.borderEdge.height, 18);
expect(div.marginEdge.height, 30);
expect(all1.borderEdge.height, 18);
@ -185,7 +185,7 @@ main() {
});
test('borderEdge.height and marginEdge.height with border-box', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.borderEdge.height, 10);
expect(all1.marginEdge.height, 22);
@ -198,7 +198,7 @@ main() {
});
test('borderEdge.width and marginEdge.width', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.borderEdge.width, 19);
expect(all1.marginEdge.width, 31);
@ -213,7 +213,7 @@ main() {
});
test('borderEdge.width and marginEdge.width with border-box', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.borderEdge.width, 11);
expect(all1.marginEdge.width, 23);
@ -229,7 +229,7 @@ main() {
div.style.border = '1px solid #fff';
div.style.margin = '6px 7px';
div.style.padding = '4px 5px';
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.borderEdge.left, all1[0].getBoundingClientRect().left);
expect(all1.borderEdge.top, all1[0].getBoundingClientRect().top);
@ -249,7 +249,7 @@ main() {
div.style.border = '1px solid #fff';
div.style.margin = '6px 7px';
div.style.padding = '4px 5px';
var all1 = queryAll('div');
var all1 = querySelectorAll('div');
all1.contentEdge.height = new Dimension.px(200);
all1.contentEdge.height = 200;
for (Element elem in all1) {

View file

@ -69,15 +69,15 @@ main() {
setUp(initPage);
test('offsetTo', () {
var itema = query('.item-a');
var itemb = query('.item-b');
var item1 = query('.item-1');
var itemii = query('.item-ii');
var level1 = query('.level-1');
var baz = query('.baz');
var bar = query('.bar');
var qux = query('.qux');
var quux = query('.quux');
var itema = querySelector('.item-a');
var itemb = querySelector('.item-b');
var item1 = querySelector('.item-1');
var itemii = querySelector('.item-ii');
var level1 = querySelector('.level-1');
var baz = querySelector('.baz');
var bar = querySelector('.bar');
var qux = querySelector('.qux');
var quux = querySelector('.quux');
var point = itema.offsetTo(itemii);
expect(point.x, 40);
@ -102,14 +102,14 @@ main() {
});
test('documentOffset', () {
var bar = query('.bar');
var baz = query('.baz');
var qux = query('.qux');
var quux = query('.quux');
var itema = query('.item-a');
var itemb = query('.item-b');
var item1 = query('.item-1');
var itemii = query('.item-ii');
var bar = querySelector('.bar');
var baz = querySelector('.baz');
var qux = querySelector('.qux');
var quux = querySelector('.quux');
var itema = querySelector('.item-a');
var itemb = querySelector('.item-b');
var item1 = querySelector('.item-1');
var itemii = querySelector('.item-ii');
expect(itema.documentOffset.x, 88);
expect(itema.documentOffset.y, inInclusiveRange(111, 160));

View file

@ -641,7 +641,7 @@ main() {
});
group('queryAll', () {
List<Element> getQueryAll() {
List<Element> getquerySelectorAll() {
return new Element.html("""
<div>
<hr/>
@ -652,59 +652,61 @@ main() {
</p>
<hr class='q'/>
</div>
""").queryAll('.q');
""").querySelectorAll('.q');
}
List<Element> getEmptyQueryAll() => new Element.tag('div').queryAll('img');
List<Element> getEmptyquerySelectorAll() =>
new Element.tag('div').querySelectorAll('img');
test('last', () {
expect(getQueryAll().last, isHRElement);
expect(getquerySelectorAll().last, isHRElement);
});
test('forEach', () {
var els = [];
getQueryAll().forEach((el) => els.add(el));
getquerySelectorAll().forEach((el) => els.add(el));
expect(els[0], isAnchorElement);
expect(els[1], isSpanElement);
expect(els[2], isHRElement);
});
test('map', () {
var texts = getQueryAll().map((el) => el.text).toList();
var texts = getquerySelectorAll().map((el) => el.text).toList();
expect(texts, equals(['Dart!', 'Hello', '']));
});
test('where', () {
var filtered = getQueryAll().where((n) => n is SpanElement).toList();
var filtered =
getquerySelectorAll().where((n) => n is SpanElement).toList();
expect(filtered.length, 1);
expect(filtered[0], isSpanElement);
expect(filtered, isElementList);
});
test('every', () {
var el = getQueryAll();
var el = getquerySelectorAll();
expect(el.every((n) => n is Element), isTrue);
expect(el.every((n) => n is SpanElement), isFalse);
});
test('any', () {
var el = getQueryAll();
var el = getquerySelectorAll();
expect(el.any((n) => n is SpanElement), isTrue);
expect(el.any((n) => n is svg.SvgElement), isFalse);
});
test('isEmpty', () {
expect(getEmptyQueryAll().isEmpty, isTrue);
expect(getQueryAll().isEmpty, isFalse);
expect(getEmptyquerySelectorAll().isEmpty, isTrue);
expect(getquerySelectorAll().isEmpty, isFalse);
});
test('length', () {
expect(getEmptyQueryAll().length, 0);
expect(getQueryAll().length, 3);
expect(getEmptyquerySelectorAll().length, 0);
expect(getquerySelectorAll().length, 3);
});
test('[]', () {
var els = getQueryAll();
var els = getquerySelectorAll();
expect(els[0], isAnchorElement);
expect(els[1], isSpanElement);
expect(els[2], isHRElement);
@ -712,7 +714,7 @@ main() {
test('iterator', () {
var els = [];
for (var subel in getQueryAll()) {
for (var subel in getquerySelectorAll()) {
els.add(subel);
}
expect(els[0], isAnchorElement);
@ -721,31 +723,34 @@ main() {
});
test('sublist', () {
expect(getQueryAll().sublist(1, 2) is List<Element>, isTrue);
expect(getquerySelectorAll().sublist(1, 2) is List<Element>, isTrue);
});
testUnsupported('[]=', () => getQueryAll()[1] = new Element.tag('br'));
testUnsupported('add', () => getQueryAll().add(new Element.tag('br')));
testUnsupported(
'[]=', () => getquerySelectorAll()[1] = new Element.tag('br'));
testUnsupported(
'add', () => getquerySelectorAll().add(new Element.tag('br')));
testUnsupported('addAll', () {
getQueryAll().addAll([
getquerySelectorAll().addAll([
new Element.tag('span'),
new Element.tag('a'),
new Element.tag('h1')
]);
});
testUnsupported('sort', () => getQueryAll().sort((a1, a2) => true));
testUnsupported('sort', () => getquerySelectorAll().sort((a1, a2) => true));
testUnsupported('setRange', () {
getQueryAll().setRange(0, 1, [new BRElement()]);
getquerySelectorAll().setRange(0, 1, [new BRElement()]);
});
testUnsupported('removeRange', () => getQueryAll().removeRange(0, 1));
testUnsupported(
'removeRange', () => getquerySelectorAll().removeRange(0, 1));
testUnsupported('clear', () => getQueryAll().clear());
testUnsupported('clear', () => getquerySelectorAll().clear());
testUnsupported('removeLast', () => getQueryAll().removeLast());
testUnsupported('removeLast', () => getquerySelectorAll().removeLast());
});
group('functional', () {
@ -839,30 +844,30 @@ main() {
document.body.append(elem6);
var firedEvent = false;
var elems = queryAll('.a');
queryAll('.a').onClick.listen((event) {
var elems = querySelectorAll('.a');
querySelectorAll('.a').onClick.listen((event) {
firedEvent = true;
});
expect(firedEvent, false);
query('.c').click();
querySelector('.c').click();
expect(firedEvent, false);
query('#wat').click();
querySelector('#wat').click();
expect(firedEvent, true);
var firedEvent4 = false;
queryAll('.a').onClick.matches('.d').listen((event) {
querySelectorAll('.a').onClick.matches('.d').listen((event) {
firedEvent4 = true;
});
expect(firedEvent4, false);
query('.c').click();
querySelector('.c').click();
expect(firedEvent4, false);
query('#wat').click();
querySelector('#wat').click();
expect(firedEvent4, false);
query('#cookie').click();
querySelector('#cookie').click();
expect(firedEvent4, true);
var firedEvent2 = false;
queryAll('.a').onClick.listen((event) {
querySelectorAll('.a').onClick.listen((event) {
firedEvent2 = true;
});
Element elem2 = new Element.html('<div class="a"><br/>');
@ -874,7 +879,7 @@ main() {
expect(firedEvent2, false);
var firedEvent3 = false;
queryAll(':root').onClick.matches('.a').listen((event) {
querySelectorAll(':root').onClick.matches('.a').listen((event) {
firedEvent3 = true;
});
Element elem3 = new Element.html('<div class="d"><br/>');
@ -886,11 +891,11 @@ main() {
expect(firedEvent3, true);
var firedEvent5 = false;
queryAll(':root').onClick.matches('.e').listen((event) {
querySelectorAll(':root').onClick.matches('.e').listen((event) {
firedEvent5 = true;
});
expect(firedEvent5, false);
query('.i').click();
querySelector('.i').click();
expect(firedEvent5, true);
});
@ -940,7 +945,7 @@ main() {
ElementList<Element> makeElementList() =>
(new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>"))
.queryAll('br');
.querySelectorAll('br');
test('hashCode', () {
var nodes = makeElementList();

View file

@ -15,7 +15,7 @@ main() {
<div id='div1'>
Hello World!
</div>'''));
Element e = document.query('#div1');
Element e = document.querySelector('#div1');
expect(e, isNotNull);
checkNoSuchMethod(() {

View file

@ -15,7 +15,7 @@ main() {
<div id='div1'>
Hello World!
</div>'''));
Element e = document.query('#div1');
Element e = document.querySelector('#div1');
Element e2 = new Element.html(r"<div id='xx'>XX</div>");
expect(e, isNotNull);

View file

@ -38,7 +38,7 @@ main() {
test('IsList', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
expect(eachChecked, isList);
@ -47,11 +47,11 @@ main() {
test('Every', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -69,11 +69,11 @@ main() {
test('Some', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -91,11 +91,11 @@ main() {
test('Filter', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -113,9 +113,9 @@ main() {
test('IsEmpty', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> emptyDiv = document.query('#emptyDiv').children;
List<Element> emptyDiv = document.querySelector('#emptyDiv').children;
expect(someChecked.length, 4);
expect(emptyDiv.length, 0);
@ -137,11 +137,11 @@ main() {
test('ForEach', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -169,11 +169,11 @@ main() {
// Uses iterator.
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -191,7 +191,7 @@ main() {
test('Last', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
expect(someChecked.length, 4);
@ -202,9 +202,9 @@ main() {
test('IndexOf', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(someChecked.length, 4);
expect(noneChecked.length, 4);
@ -229,9 +229,9 @@ main() {
test('LastIndexOf', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(someChecked.length, 4);
expect(noneChecked.length, 4);

View file

@ -13,7 +13,7 @@ main() {
element.innerHtml = 'Hello World';
document.body.append(element);
element = document.query('#test');
element = document.querySelector('#test');
expect(element.innerHtml, 'Hello World');
element.remove();
});

View file

@ -23,7 +23,7 @@ main() {
predicate((x) => x is ImageElement, 'is an ImageElement');
test('query', () {
Element e = query('#testcanvas');
Element e = querySelector('#testcanvas');
expect(e, isNotNull);
expect(e.id, 'testcanvas');
expect(e, isCanvasElement);
@ -31,18 +31,18 @@ main() {
});
test('query (None)', () {
Element e = query('#nothere');
Element e = querySelector('#nothere');
expect(e, isNull);
});
test('queryAll (One)', () {
List l = queryAll('canvas');
List l = querySelectorAll('canvas');
expect(l.length, 1);
expect(l[0], canvas);
});
test('queryAll (Multiple)', () {
List l = queryAll('img');
List l = querySelectorAll('img');
expect(l.length, 2);
expect(l[0], isImageElement);
expect(l[1], isImageElement);
@ -50,7 +50,7 @@ main() {
});
test('queryAll (None)', () {
List l = queryAll('video');
List l = querySelectorAll('video');
expect(l.isEmpty, isTrue);
});
}

View file

@ -31,15 +31,15 @@ main() {
]);
test('queryAll', () {
List<Node> all = queryAll('*');
List<Node> all = querySelectorAll('*');
for (var e in all) {
expect(e, isElement);
}
});
test('document.queryAll', () {
List<Element> all1 = queryAll('*');
List<Element> all2 = document.queryAll('*');
List<Element> all1 = querySelectorAll('*');
List<Element> all2 = document.querySelectorAll('*');
expect(all1.length, equals(all2.length));
for (var i = 0; i < all1.length; ++i) {
expect(all1[i], equals(all2[i]));
@ -47,7 +47,7 @@ main() {
});
test('queryAll-canvas', () {
List<CanvasElement> all = queryAll('canvas');
List<CanvasElement> all = querySelectorAll('canvas');
for (var e in all) {
expect(e, isCanvasElement);
}
@ -55,14 +55,14 @@ main() {
});
test('queryAll-contains', () {
List<Element> all = queryAll('*');
List<Element> all = querySelectorAll('*');
for (var e in all) {
expect(all.contains(e), isTrue);
}
});
test('queryAll-where', () {
List<Element> all = queryAll('*');
List<Element> all = querySelectorAll('*');
Iterable<CanvasElement> canvases = all.where((e) => e is CanvasElement);
for (var e in canvases) {
expect(e is CanvasElement, isTrue);
@ -71,7 +71,7 @@ main() {
});
test('node.queryAll', () {
List<Element> list = div.queryAll('*');
List<Element> list = div.querySelectorAll('*');
expect(list.length, equals(5));
expect(list[0], isDivElement);
expect(list[1], isCanvasElement);
@ -81,7 +81,7 @@ main() {
});
test('immutable', () {
List<Element> list = div.queryAll('*');
List<Element> list = div.querySelectorAll('*');
int len = list.length;
expect(() {
list.add(new DivElement());

View file

@ -43,7 +43,7 @@ main() {
expect(() {
init();
expect(queryAll('.foo'), equals([div1, paragraph2]));
expect(querySelectorAll('.foo'), equals([div1, paragraph2]));
}, expectation);
});
@ -64,7 +64,7 @@ main() {
expect(() {
init();
expect(shadowRoot.queryAll('.foo'), equals([paragraph1]));
expect(shadowRoot.querySelectorAll('.foo'), equals([paragraph1]));
}, expectation);
});

View file

@ -26,10 +26,10 @@ main() {
''',
validator: new NodeValidatorBuilder()..allowSvg());
var e = document.query('#svg1');
var e = document.querySelector('#svg1');
expect(e, isNotNull);
svg.RectElement r = document.query('#rect1');
svg.RectElement r = document.querySelector('#rect1');
expect(r.x.baseVal.value, 10);
expect(r.y.baseVal.value, 20);
expect(r.height.baseVal.value, 40);
@ -75,7 +75,7 @@ main() {
test('rect_isChecks', () {
var div = insertTestDiv();
var r = document.query('#rect1');
var r = document.querySelector('#rect1');
// Direct inheritance chain
expect(r, isSvgElement);
@ -124,7 +124,7 @@ main() {
testRect(name, checker) {
test(name, () {
var div = insertTestDiv();
var r = document.query('#rect1');
var r = document.querySelector('#rect1');
checker(r);
div.remove();
});

View file

@ -19,11 +19,11 @@ void main() {
test('', () {
if (!TrackElement.supported) return;
document.body.append(new TrackElement()..defaultValue = true);
if (!document.query('track').defaultValue) {
if (!document.querySelector('track').defaultValue) {
throw 'Expected default value to be true';
}
document.query('track').defaultValue = false;
if (document.query('track').defaultValue) {
document.querySelector('track').defaultValue = false;
if (document.querySelector('track').defaultValue) {
throw 'Expected default value to be false';
}
});

View file

@ -11,15 +11,15 @@ main() {
predicate((x) => x is List<StyleSheet>, 'is a List<StyleSheet>');
test('NodeList', () {
List<Node> asList = window.document.queryAll('body');
List<Node> asList = window.document.querySelectorAll('body');
// Check it's Iterable
int counter = 0;
for (Node node in window.document.queryAll('body')) {
for (Node node in window.document.querySelectorAll('body')) {
counter++;
}
expect(counter, 1);
counter = 0;
window.document.queryAll('body').forEach((e) {
window.document.querySelectorAll('body').forEach((e) {
counter++;
});
expect(counter, 1);

View file

@ -23,8 +23,8 @@ main() {
test('type-check', () {
expect(foo, isUnknownElement);
expect(bar, isUnknownElement);
expect(query('#foo'), equals(foo));
expect(query('#bar'), equals(bar));
expect(querySelector('#foo'), equals(foo));
expect(querySelector('#bar'), equals(bar));
});
test('dispatch-fail', () {

View file

@ -114,13 +114,13 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.documentElement.children.add(listElement);
var elements = document.queryAll('li');
var elements = document.querySelectorAll('li');
expect(elements.style.backgroundColor, equals('red'));
expect(elements.style.borderLeftWidth, equals('10px'));
elements = document.queryAll('.baz');
elements = document.querySelectorAll('.baz');
expect(elements.style.backgroundColor, equals('black'));
expect(elements.style.borderLeftWidth, equals(''));
elements = document.queryAll('.bar');
elements = document.querySelectorAll('.bar');
expect(elements.style.backgroundColor, equals('red'));
});
@ -134,25 +134,25 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.documentElement.children.add(listElement);
var elements = document.queryAll('li');
var elements = document.querySelectorAll('li');
elements.style.backgroundColor = 'green';
expect(elements.style.backgroundColor, equals('green'));
expect(elements.style.borderLeftWidth, equals('10px'));
elements = document.queryAll('.baz');
elements = document.querySelectorAll('.baz');
expect(elements.style.backgroundColor, equals('green'));
elements.style.backgroundColor = 'yellow';
expect(elements.style.backgroundColor, equals('yellow'));
expect(elements.style.borderLeftWidth, equals(''));
elements = document.queryAll('.bar');
elements = document.querySelectorAll('.bar');
expect(elements.style.backgroundColor, equals('green'));
elements = document.queryAll('#wat');
elements = document.querySelectorAll('#wat');
expect(elements.style.backgroundColor, equals('yellow'));
elements.style.borderLeftWidth = '18px';
expect(elements.style.borderLeftWidth, equals('18px'));
elements = document.queryAll('li');
elements = document.querySelectorAll('li');
expect(elements.style.borderLeftWidth, equals('10px'));
});

View file

@ -37,12 +37,12 @@ class C extends HtmlElement {
return;
}
var t = div.query('#t');
var v = div.query('#v');
var w = div.query('#w');
var t = div.querySelector('#t');
var v = div.querySelector('#v');
var w = div.querySelector('#w');
expect(query('x-b:not(:unresolved)'), this);
expect(queryAll(':unresolved'), [v, w]);
expect(querySelector('x-b:not(:unresolved)'), this);
expect(querySelectorAll(':unresolved'), [v, w]);
// As per:
// http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-parsing
@ -91,7 +91,7 @@ main() {
upgradeCustomElements(div);
expect(C.createdInvocations, 2);
expect(div.query('#w') is B, isTrue);
expect(div.querySelector('#w') is B, isTrue);
});
test('nesting of constructors', NestedElement.test);

View file

@ -139,7 +139,7 @@ main() {
treeSanitizer: new NullTreeSanitizer());
upgradeCustomElements(element);
document.body.nodes.add(element);
var queried = query(tag) as CustomType;
var queried = querySelector(tag) as CustomType;
expect(queried, isNotNull);
expect(queried is CustomType, isTrue);
@ -154,7 +154,7 @@ main() {
treeSanitizer: new NullTreeSanitizer());
upgradeCustomElements(element);
document.body.nodes.add(element);
var queried = query('#someid') as CustomType;
var queried = querySelector('#someid') as CustomType;
expect(queried, isNotNull);
expect(queried is CustomType, isTrue);

View file

@ -13,10 +13,10 @@ main() {
var element = new Element.tag('x-basic1')..id = 'basic1';
document.body.nodes.add(element);
var queryById = query('#basic1');
var queryById = querySelector('#basic1');
expect(queryById, equals(element));
var queryByTag = queryAll('x-basic1');
var queryByTag = querySelectorAll('x-basic1');
expect(queryByTag.length, equals(1));
expect(queryByTag[0], equals(element));
});
@ -27,10 +27,10 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.body.nodes.add(element);
var queryById = query('#basic2');
var queryById = querySelector('#basic2');
expect(queryById is Element, isTrue);
var queryByTag = queryAll('x-basic2');
var queryByTag = querySelectorAll('x-basic2');
expect(queryByTag.length, equals(1));
expect(queryByTag[0], equals(queryById));
});
@ -41,7 +41,7 @@ main() {
treeSanitizer: new NullTreeSanitizer());
document.body.nodes.add(element);
var queryById = query('#basic3');
var queryById = querySelector('#basic3');
expect(queryById is DivElement, isTrue);
});
}

View file

@ -25,7 +25,7 @@ main() {
expect(sessionStorage, equals(window.sessionStorage));
});
test('unknown', () {
var test = document.query('#test');
var test = document.querySelector('#test');
expect(element, equals(test));
});
}

View file

@ -33,7 +33,7 @@ main() {
test('is', () {
try {
var list = document.query('#browsers');
var list = document.querySelector('#browsers');
expect(list, isDataListElement);
} catch (e) {
expect(DataListElement.supported, false);
@ -42,8 +42,8 @@ main() {
test('list', () {
try {
var list = document.query('#browsers') as DataListElement;
var input = document.query('#input') as InputElement;
var list = document.querySelector('#browsers') as DataListElement;
var input = document.querySelector('#input') as InputElement;
expect(input.list, list);
} catch (e) {
expect(DataListElement.supported, false);
@ -52,7 +52,8 @@ main() {
test('options', () {
try {
var options = (document.query('#browsers') as DataListElement).options;
var options =
(document.querySelector('#browsers') as DataListElement).options;
expect(options.length, 5);
} catch (e) {
expect(DataListElement.supported, false);

View file

@ -32,7 +32,7 @@ main() {
</ResultSet>''',
'text/xml');
var rs = doc.query('ResultSet');
var rs = doc.querySelector('ResultSet');
expect(rs, isNotNull);
});
@ -50,7 +50,7 @@ main() {
expect(doc.adoptNode(div), div);
expect(div.ownerDocument, doc);
doc.body.nodes.add(div);
expect(doc.query('#foo').text, 'bar');
expect(doc.querySelector('#foo').text, 'bar');
});
test('importNode', () {
@ -60,7 +60,7 @@ main() {
expect(div2, notEquals(div));
expect(div2.ownerDocument, doc);
doc.body.nodes.add(div2);
expect(doc.query('#foo').text, 'bar');
expect(doc.querySelector('#foo').text, 'bar');
});
test('typeTest1', () {

View file

@ -163,8 +163,8 @@ main() {
test('query searches the fragment', () {
var fragment = new DocumentFragment.html(
"<div class='foo'><a>foo</a><b>bar</b></div>");
expect(fragment.query(".foo a").tagName, "A");
expect(
_nodeStrings(fragment.queryAll<Element>(".foo *")), equals(["A", "B"]));
expect(fragment.querySelector(".foo a").tagName, "A");
expect(_nodeStrings(fragment.querySelectorAll<Element>(".foo *")),
equals(["A", "B"]));
});
}

View file

@ -278,7 +278,7 @@ main() {
test('listClasses=', () {
var elements = listElementSetup();
elements.classes = ['foo', 'qux'];
elements = document.queryAll('li');
elements = document.querySelectorAll('li');
for (Element e in elements) {
expect(e.classes, equals(['foo', 'qux']));
expect(extractClasses(e), equals(['foo', 'qux']));

View file

@ -42,7 +42,7 @@ main() {
setUp(initDiv);
test('contentEdge.height', () {
var all1 = queryAll('#test');
var all1 = querySelectorAll('#test');
expect(all1.contentEdge.height, 10);
expect(all1[0].getComputedStyle().getPropertyValue('height'), '10px');
@ -68,7 +68,7 @@ main() {
});
test('contentEdge.height with border-box', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.contentEdge.height, 2);
div.style.padding = '20pc';
@ -78,7 +78,7 @@ main() {
});
test('contentEdge.width', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
expect(all1.contentEdge.width, 11);
expect(all1[0].getComputedStyle().getPropertyValue('width'), '11px');
@ -101,7 +101,7 @@ main() {
});
test('contentEdge.width with border-box', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.contentEdge.width, 3);
div.style.padding = '20pc';
@ -111,7 +111,7 @@ main() {
});
test('paddingEdge.height', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
expect(all1.paddingEdge.height, 18);
all1[0].style.visibility = 'hidden';
expect(all1.paddingEdge.height, 18);
@ -126,7 +126,7 @@ main() {
});
test('paddingEdge.height with border-box', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.paddingEdge.height, 10);
div.style.padding = '20pc';
@ -136,7 +136,7 @@ main() {
});
test('paddingEdge.width', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
expect(all1.paddingEdge.width, 19);
all1[0].style.visibility = 'hidden';
expect(all1.paddingEdge.width, 19);
@ -152,7 +152,7 @@ main() {
});
test('paddingEdge.width with border-box', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.paddingEdge.width, 11);
div.style.padding = '20pc';
@ -162,7 +162,7 @@ main() {
});
test('borderEdge.height and marginEdge.height', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
expect(div.borderEdge.height, 18);
expect(div.marginEdge.height, 30);
expect(all1.borderEdge.height, 18);
@ -181,7 +181,7 @@ main() {
});
test('borderEdge.height and marginEdge.height with border-box', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.borderEdge.height, 10);
expect(all1.marginEdge.height, 22);
@ -194,7 +194,7 @@ main() {
});
test('borderEdge.width and marginEdge.width', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
expect(all1.borderEdge.width, 19);
expect(all1.marginEdge.width, 31);
@ -209,7 +209,7 @@ main() {
});
test('borderEdge.width and marginEdge.width with border-box', () {
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
div.style.boxSizing = 'border-box';
expect(all1.borderEdge.width, 11);
expect(all1.marginEdge.width, 23);
@ -225,7 +225,7 @@ main() {
div.style.border = '1px solid #fff';
div.style.margin = '6px 7px';
div.style.padding = '4px 5px';
var all1 = queryAll('#test');
var all1 = document.querySelectorAll('#test');
expect(all1.borderEdge.left, all1[0].getBoundingClientRect().left);
expect(all1.borderEdge.top, all1[0].getBoundingClientRect().top);
@ -245,7 +245,7 @@ main() {
div.style.border = '1px solid #fff';
div.style.margin = '6px 7px';
div.style.padding = '4px 5px';
var all1 = queryAll('div');
var all1 = document.querySelectorAll('div');
all1.contentEdge.height = new Dimension.px(200);
all1.contentEdge.height = 200;
for (Element elem in all1) {

View file

@ -66,15 +66,15 @@ main() {
setUp(initPage);
test('offsetTo', () {
var itema = query('.item-a');
var itemb = query('.item-b');
var item1 = query('.item-1');
var itemii = query('.item-ii');
var level1 = query('.level-1');
var baz = query('.baz');
var bar = query('.bar');
var qux = query('.qux');
var quux = query('.quux');
var itema = querySelector('.item-a');
var itemb = querySelector('.item-b');
var item1 = querySelector('.item-1');
var itemii = querySelector('.item-ii');
var level1 = querySelector('.level-1');
var baz = querySelector('.baz');
var bar = querySelector('.bar');
var qux = querySelector('.qux');
var quux = querySelector('.quux');
var point = itema.offsetTo(itemii);
expect(point.x, 40);
@ -99,14 +99,14 @@ main() {
});
test('documentOffset', () {
var bar = query('.bar');
var baz = query('.baz');
var qux = query('.qux');
var quux = query('.quux');
var itema = query('.item-a');
var itemb = query('.item-b');
var item1 = query('.item-1');
var itemii = query('.item-ii');
var bar = querySelector('.bar');
var baz = querySelector('.baz');
var qux = querySelector('.qux');
var quux = querySelector('.quux');
var itema = querySelector('.item-a');
var itemb = querySelector('.item-b');
var item1 = querySelector('.item-1');
var itemii = querySelector('.item-ii');
expect(itema.documentOffset.x, 88);
expect(itema.documentOffset.y, inInclusiveRange(111, 160));

View file

@ -650,8 +650,8 @@ main() {
});
});
group('queryAll', () {
List<Element> getQueryAll() {
group('querySelectorAll', () {
List<Element> getQuerySelectorAll() {
return new Element.html("""
<div>
<hr/>
@ -662,59 +662,61 @@ main() {
</p>
<hr class='q'/>
</div>
""").queryAll('.q');
""").querySelectorAll('.q');
}
List<Element> getEmptyQueryAll() => new Element.tag('div').queryAll('img');
List<Element> getEmptyQuerySelectorAll() =>
new Element.tag('div').querySelectorAll('img');
test('last', () {
expect(getQueryAll().last, isHRElement);
expect(getQuerySelectorAll().last, isHRElement);
});
test('forEach', () {
var els = [];
getQueryAll().forEach((el) => els.add(el));
getQuerySelectorAll().forEach((el) => els.add(el));
expect(els[0], isAnchorElement);
expect(els[1], isSpanElement);
expect(els[2], isHRElement);
});
test('map', () {
var texts = getQueryAll().map((el) => el.text).toList();
var texts = getQuerySelectorAll().map((el) => el.text).toList();
expect(texts, equals(['Dart!', 'Hello', '']));
});
test('where', () {
var filtered = getQueryAll().where((n) => n is SpanElement).toList();
var filtered =
getQuerySelectorAll().where((n) => n is SpanElement).toList();
expect(filtered.length, 1);
expect(filtered[0], isSpanElement);
expect(filtered, isElementList);
});
test('every', () {
var el = getQueryAll();
var el = getQuerySelectorAll();
expect(el.every((n) => n is Element), isTrue);
expect(el.every((n) => n is SpanElement), isFalse);
});
test('any', () {
var el = getQueryAll();
var el = getQuerySelectorAll();
expect(el.any((n) => n is SpanElement), isTrue);
expect(el.any((n) => n is svg.SvgElement), isFalse);
});
test('isEmpty', () {
expect(getEmptyQueryAll().isEmpty, isTrue);
expect(getQueryAll().isEmpty, isFalse);
expect(getEmptyQuerySelectorAll().isEmpty, isTrue);
expect(getQuerySelectorAll().isEmpty, isFalse);
});
test('length', () {
expect(getEmptyQueryAll().length, 0);
expect(getQueryAll().length, 3);
expect(getEmptyQuerySelectorAll().length, 0);
expect(getQuerySelectorAll().length, 3);
});
test('[]', () {
var els = getQueryAll();
var els = getQuerySelectorAll();
expect(els[0], isAnchorElement);
expect(els[1], isSpanElement);
expect(els[2], isHRElement);
@ -722,7 +724,7 @@ main() {
test('iterator', () {
var els = [];
for (var subel in getQueryAll()) {
for (var subel in getQuerySelectorAll()) {
els.add(subel);
}
expect(els[0], isAnchorElement);
@ -731,31 +733,34 @@ main() {
});
test('sublist', () {
expect(getQueryAll().sublist(1, 2) is List<Element>, isTrue);
expect(getQuerySelectorAll().sublist(1, 2) is List<Element>, isTrue);
});
testUnsupported('[]=', () => getQueryAll()[1] = new Element.tag('br'));
testUnsupported('add', () => getQueryAll().add(new Element.tag('br')));
testUnsupported(
'[]=', () => getQuerySelectorAll()[1] = new Element.tag('br'));
testUnsupported(
'add', () => getQuerySelectorAll().add(new Element.tag('br')));
testUnsupported('addAll', () {
getQueryAll().addAll([
getQuerySelectorAll().addAll([
new Element.tag('span'),
new Element.tag('a'),
new Element.tag('h1')
]);
});
testUnsupported('sort', () => getQueryAll().sort((a1, a2) => 0));
testUnsupported('sort', () => getQuerySelectorAll().sort((a1, a2) => 0));
testUnsupported('setRange', () {
getQueryAll().setRange(0, 1, [new BRElement()]);
getQuerySelectorAll().setRange(0, 1, [new BRElement()]);
});
testUnsupported('removeRange', () => getQueryAll().removeRange(0, 1));
testUnsupported(
'removeRange', () => getQuerySelectorAll().removeRange(0, 1));
testUnsupported('clear', () => getQueryAll().clear());
testUnsupported('clear', () => getQuerySelectorAll().clear());
testUnsupported('removeLast', () => getQueryAll().removeLast());
testUnsupported('removeLast', () => getQuerySelectorAll().removeLast());
});
group('functional', () {
@ -849,30 +854,30 @@ main() {
document.body.append(elem6);
var firedEvent = false;
var elems = queryAll('.a');
queryAll('.a').onClick.listen((event) {
var elems = querySelectorAll('.a');
querySelectorAll('.a').onClick.listen((event) {
firedEvent = true;
});
expect(firedEvent, false);
query('.c').click();
querySelector('.c').click();
expect(firedEvent, false);
query('#wat').click();
querySelector('#wat').click();
expect(firedEvent, true);
var firedEvent4 = false;
queryAll('.a').onClick.matches('.d').listen((event) {
querySelectorAll('.a').onClick.matches('.d').listen((event) {
firedEvent4 = true;
});
expect(firedEvent4, false);
query('.c').click();
querySelector('.c').click();
expect(firedEvent4, false);
query('#wat').click();
querySelector('#wat').click();
expect(firedEvent4, false);
query('#cookie').click();
querySelector('#cookie').click();
expect(firedEvent4, true);
var firedEvent2 = false;
queryAll('.a').onClick.listen((event) {
querySelectorAll('.a').onClick.listen((event) {
firedEvent2 = true;
});
Element elem2 = new Element.html('<div class="a"><br/>');
@ -884,7 +889,7 @@ main() {
expect(firedEvent2, false);
var firedEvent3 = false;
queryAll(':root').onClick.matches('.a').listen((event) {
querySelectorAll(':root').onClick.matches('.a').listen((event) {
firedEvent3 = true;
});
Element elem3 = new Element.html('<div class="d"><br/>');
@ -896,11 +901,11 @@ main() {
expect(firedEvent3, true);
var firedEvent5 = false;
queryAll(':root').onClick.matches('.e').listen((event) {
querySelectorAll(':root').onClick.matches('.e').listen((event) {
firedEvent5 = true;
});
expect(firedEvent5, false);
query('.i').click();
querySelector('.i').click();
expect(firedEvent5, true);
});
@ -952,7 +957,7 @@ main() {
ElementList<Element> makeElementList() =>
(new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>"))
.queryAll('br');
.querySelectorAll('br');
test('hashCode', () {
var nodes = makeElementList();

View file

@ -11,7 +11,7 @@ main() {
<div id='div1'>
Hello World!
</div>'''));
Element e = document.query('#div1');
Element e = document.querySelector('#div1');
expect(e, isNotNull);
expect(() {

View file

@ -11,7 +11,7 @@ main() {
<div id='div1'>
Hello World!
</div>'''));
Element e = document.query('#div1');
Element e = document.querySelector('#div1');
Element e2 = new Element.html(r"<div id='xx'>XX</div>");
expect(e, isNotNull);

View file

@ -37,7 +37,7 @@ main() {
test('IsList', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
expect(eachChecked is List, isTrue);
@ -46,11 +46,11 @@ main() {
test('Every', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -68,11 +68,11 @@ main() {
test('Some', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -90,11 +90,11 @@ main() {
test('Filter', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -112,9 +112,9 @@ main() {
test('IsEmpty', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> emptyDiv = document.query('#emptyDiv').children;
List<Element> emptyDiv = document.querySelector('#emptyDiv').children;
expect(someChecked.length, 4);
expect(emptyDiv.length, 0);
@ -136,11 +136,11 @@ main() {
test('ForEach', () {
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -168,11 +168,11 @@ main() {
// Uses iterator.
Element root = insertTestDiv();
List<Element> eachChecked = document.query('#allChecked').children;
List<Element> eachChecked = document.querySelector('#allChecked').children;
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(eachChecked.length, 4);
expect(someChecked.length, 4);
@ -190,7 +190,7 @@ main() {
test('Last', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
expect(someChecked.length, 4);
@ -201,9 +201,9 @@ main() {
test('IndexOf', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(someChecked.length, 4);
expect(noneChecked.length, 4);
@ -228,9 +228,9 @@ main() {
test('LastIndexOf', () {
Element root = insertTestDiv();
List<Element> someChecked = document.query('#someChecked').children;
List<Element> someChecked = document.querySelector('#someChecked').children;
List<Element> noneChecked = document.query('#noneChecked').children;
List<Element> noneChecked = document.querySelector('#noneChecked').children;
expect(someChecked.length, 4);
expect(noneChecked.length, 4);

View file

@ -11,7 +11,7 @@ main() {
element.innerHtml = 'Hello World';
document.body.append(element);
element = document.query('#test');
element = document.querySelector('#test');
expect(element.innerHtml, 'Hello World');
element.remove();
});

View file

@ -19,7 +19,7 @@ main() {
predicate((x) => x is ImageElement, 'is an ImageElement');
test('query', () {
Element e = query('#testcanvas');
Element e = querySelector('#testcanvas');
expect(e, isNotNull);
expect(e.id, 'testcanvas');
expect(e, isCanvasElement);
@ -27,18 +27,18 @@ main() {
});
test('query (None)', () {
Element e = query('#nothere');
Element e = querySelector('#nothere');
expect(e, isNull);
});
test('queryAll (One)', () {
List l = queryAll('canvas');
List l = querySelectorAll('canvas');
expect(l.length, 1);
expect(l[0], canvas);
});
test('queryAll (Multiple)', () {
List l = queryAll('img');
List l = querySelectorAll('img');
expect(l.length, 2);
expect(l[0], isImageElement);
expect(l[1], isImageElement);
@ -46,7 +46,7 @@ main() {
});
test('queryAll (None)', () {
List l = queryAll('video');
List l = querySelectorAll('video');
expect(l.isEmpty, isTrue);
});
}

View file

@ -26,39 +26,39 @@ main() {
new CanvasElement()
]);
test('queryAll', () {
List<Node> all = queryAll('*');
test('querySelectorAll', () {
List<Node> all = querySelectorAll('*');
for (var e in all) {
expect(e, isElement);
}
});
test('document.queryAll', () {
List<Element> all1 = queryAll('*');
List<Element> all2 = document.queryAll('*');
test('document.querySelectorAll', () {
List<Element> all1 = querySelectorAll('*');
List<Element> all2 = document.querySelectorAll('*');
expect(all1.length, equals(all2.length));
for (var i = 0; i < all1.length; ++i) {
expect(all1[i], equals(all2[i]));
}
});
test('queryAll-canvas', () {
var all = queryAll('canvas');
test('querySelectorAll-canvas', () {
var all = querySelectorAll('canvas');
for (var e in all) {
expect(e, isCanvasElement);
}
expect(all.length, equals(2));
});
test('queryAll-contains', () {
List<Element> all = queryAll('*');
test('querySelectorAll-contains', () {
List<Element> all = querySelectorAll('*');
for (var e in all) {
expect(all.contains(e), isTrue);
}
});
test('queryAll-where', () {
List<Element> all = queryAll('*');
test('querySelectorAll-where', () {
List<Element> all = querySelectorAll('*');
var canvases = all.where((e) => e is CanvasElement);
for (var e in canvases) {
expect(e is CanvasElement, isTrue);
@ -66,8 +66,8 @@ main() {
expect(canvases.length, equals(2));
});
test('node.queryAll', () {
List<Element> list = div.queryAll('*');
test('node.querySelectorAll', () {
List<Element> list = div.querySelectorAll('*');
expect(list.length, equals(5));
expect(list[0], isDivElement);
expect(list[1], isCanvasElement);
@ -77,7 +77,7 @@ main() {
});
test('immutable', () {
List<Element> list = div.queryAll('*');
List<Element> list = div.querySelectorAll('*');
int len = list.length;
expect(() {
list.add(new DivElement());

View file

@ -39,7 +39,7 @@ main() {
expect(() {
init();
expect(queryAll('.foo'), equals([div1, paragraph2]));
expect(querySelectorAll('.foo'), equals([div1, paragraph2]));
}, expectation);
});
@ -60,7 +60,7 @@ main() {
expect(() {
init();
expect(shadowRoot.queryAll('.foo'), equals([paragraph1]));
expect(shadowRoot.querySelectorAll('.foo'), equals([paragraph1]));
}, expectation);
});

View file

@ -20,10 +20,10 @@ main() {
</svg>
''', validator: new NodeValidatorBuilder()..allowSvg());
var e = document.query('#svg1');
var e = document.querySelector('#svg1');
expect(e, isNotNull);
svg.RectElement r = document.query('#rect1');
svg.RectElement r = document.querySelector('#rect1');
expect(r.x.baseVal.value, 10);
expect(r.y.baseVal.value, 20);
expect(r.height.baseVal.value, 40);
@ -72,7 +72,7 @@ main() {
test('rect_isChecks', () {
var div = insertTestDiv();
var r = document.query('#rect1');
var r = document.querySelector('#rect1');
// Direct inheritance chain
expect(r, isSvgElement);
@ -121,7 +121,7 @@ main() {
testRect(name, checker) {
test(name, () {
var div = insertTestDiv();
var r = document.query('#rect1');
var r = document.querySelector('#rect1');
checker(r);
div.remove();
});

View file

@ -17,7 +17,7 @@ void main() {
test('', () {
if (!TrackElement.supported) return;
document.body.append(new TrackElement()..defaultValue = true);
var trackElement = document.query('track') as TrackElement;
var trackElement = document.querySelector('track') as TrackElement;
if (!trackElement.defaultValue) {
throw 'Expected default value to be true';
}

View file

@ -7,15 +7,15 @@ main() {
predicate((x) => x is List<StyleSheet>, 'is a List<StyleSheet>');
test('NodeList', () {
List<Element> asList = window.document.queryAll('body');
List<Element> asList = window.document.querySelectorAll('body');
// Check it's Iterable
int counter = 0;
for (Element node in window.document.queryAll('body')) {
for (Element node in window.document.querySelectorAll('body')) {
counter++;
}
expect(counter, 1);
counter = 0;
window.document.queryAll('body').forEach((e) {
window.document.querySelectorAll('body').forEach((e) {
counter++;
});
expect(counter, 1);

View file

@ -19,8 +19,8 @@ main() {
test('type-check', () {
expect(foo, isUnknownElement);
expect(bar, isUnknownElement);
expect(query('#foo'), equals(foo));
expect(query('#bar'), equals(bar));
expect(querySelector('#foo'), equals(foo));
expect(querySelector('#bar'), equals(bar));
});
test('dispatch-fail', () {

View file

@ -9925,9 +9925,6 @@
"dart_action": "unstable",
"members": {
"IDBVersionChangeEvent": {},
"Xyzzy": {
"support_level": "untriaged"
},
"dataLoss": {
"support_level": "untriaged"
},
@ -19156,7 +19153,20 @@
"support_level": "untriaged"
},
"ServiceWorker": {
"members": {},
"members": {
"onerror": {
"support_level": "untriaged"
},
"postMessage": {
"support_level": "untriaged"
},
"scriptURL": {
"support_level": "untriaged"
},
"state": {
"support_level": "untriaged"
}
},
"support_level": "untriaged"
},
"ServiceWorkerClient": {

View file

@ -381,6 +381,13 @@ interface ImageData {
[DartSuppress] readonly attribute any dataUnion;
};
[DartSupplemental,
CustomConstructor,
Constructor()
]
interface MessageChannel {
};
// See https://chromiumcodereview.appspot.com/15901002 for the V8 implementation of
// TextEncoder/TextDecoder
[DartSuppress]

View file

@ -105,11 +105,14 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', {
"@Creates('NodeList')",
"@Returns('NodeList')",
],
'Element.getBoundingClientRect': [
"@Creates('_DomRect')",
"@Returns('_DomRect|Null')", # TODO(sra): Verify and remove Null.
],
'Element.getClientRects': [
"@Creates('DomRectList')",
"@Returns('DomRectList|Null')",
],
# Methods returning Window can return a local window, or a cross-frame
# window (=Object) that needs wrapping.
@ -174,8 +177,8 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', {
# TODO(sra): We could determine the following by parsing the compound IDL
# type.
'ExtendableMessageEvent.source': [
"@Creates('Client|_ServiceWorker|MessagePort')",
"@Returns('Client|_ServiceWorker|MessagePort|Null')",
"@Creates('Client|ServiceWorker|MessagePort')",
"@Returns('Client|ServiceWorker|MessagePort|Null')",
],
'File.lastModifiedDate': [
@ -350,7 +353,7 @@ _dart2js_annotations = monitored.Dict('dartmetadata._dart2js_annotations', {
'ServiceWorkerMessageEvent.source': [
"@Creates('Null')",
"@Returns('_ServiceWorker|MessagePort')",
"@Returns('ServiceWorker|MessagePort')",
],
'ShadowRoot.getElementsByClassName': [

View file

@ -128,7 +128,6 @@ _removed_html_interfaces = [
'RadioNodeList', # Folded onto NodeList in dart2js.
'Rect',
'Response', # TODO: Symbol conflicts with Angular: dartbug.com/20937
'ServiceWorker',
'SQLTransactionSync', # Workers
'SQLTransactionSyncCallback', # Workers
'SVGAltGlyphDefElement', # Webkit only.
@ -429,7 +428,6 @@ private_html_members = monitored.Set('htmlrenamer.private_html_members', [
'Screen.availLeft',
'Screen.availTop',
'Screen.availWidth',
'ServiceWorkerGlobalScope.fetch',
'ShadowRoot.resetStyleInheritance',
'Storage.clear',
'Storage.getItem',
@ -856,8 +854,6 @@ removed_html_members = monitored.Set('htmlrenamer.removed_html_members', [
'MouseEvent.x',
'MouseEvent.y',
'Navigator.bluetooth',
'Navigator.registerServiceWorker',
'Navigator.unregisterServiceWorker',
'Navigator.isProtocolHandlerRegistered',
'Navigator.unregisterProtocolHandler',
'Navigator.usb',
@ -886,7 +882,6 @@ removed_html_members = monitored.Set('htmlrenamer.removed_html_members', [
'ParentNode.append',
'ParentNode.prepend',
'RTCPeerConnection.generateCertificate',
'ServiceWorkerMessageEvent.data',
'ShadowRoot.getElementsByTagNameNS',
'SVGElement.getPresentationAttribute',
'SVGElementInstance.on:wheel',

View file

@ -18,22 +18,6 @@ void Function(T1, T2) _wrapBinaryZone<T1, T2>(void Function(T1, T2) callback) {
return Zone.current.bindBinaryCallbackGuarded(callback);
}
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
Element query(String relativeSelectors) => document.query(relativeSelectors);
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
ElementList<Element> queryAll(String relativeSelectors) =>
document.queryAll(relativeSelectors);
/**
* Finds the first descendant element of this document that matches the
* specified group of selectors.

View file

@ -28,25 +28,6 @@ $!MEMBERS
ElementList<T> querySelectorAll<T extends Element>(String selectors) =>
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('Document.querySelector')
Element query(String relativeSelectors) => querySelector(relativeSelectors);
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('Document.querySelectorAll')
ElementList<T> queryAll<T extends Element>(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
/// Checks if [registerElement] is supported on the current platform.
bool get supportsRegisterElement {
return JS('bool', '("registerElement" in #)', this);

View file

@ -95,26 +95,5 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
this.append(new DocumentFragment.html(text, validator: validator,
treeSanitizer: treeSanitizer));
}
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('DocumentFragment.querySelector')
Element query(String relativeSelectors) {
return querySelector(relativeSelectors);
}
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@Experimental()
@DomName('DocumentFragment.querySelectorAll')
ElementList<T> queryAll<T extends Element>(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
$!MEMBERS
}

View file

@ -602,25 +602,6 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
ElementList<T> querySelectorAll<T extends Element>(String selectors) =>
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
/**
* Alias for [querySelector]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@DomName('Element.querySelector')
@Experimental()
Element query(String relativeSelectors) => querySelector(relativeSelectors);
/**
* Alias for [querySelectorAll]. Note this function is deprecated because its
* semantics will be changing in the future.
*/
@deprecated
@DomName('Element.querySelectorAll')
@Experimental()
ElementList<T> queryAll<T extends Element>(String relativeSelectors) =>
querySelectorAll(relativeSelectors);
/**
* The set of CSS classes applied to this element.
*
@ -784,8 +765,6 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
@DomName('Element.getClientRects')
@DocsEditable()
@Returns('DomRectList|Null')
@Creates('DomRectList')
List<Rectangle> getClientRects() {
var value = _getClientRects();
@ -855,31 +834,6 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS {
*/
void attributeChanged(String name, String oldValue, String newValue) {}
// Hooks to support custom WebComponents.
@Creates('Null') // Set from Dart code; does not instantiate a native type.
Element _xtag;
/**
* Experimental support for [web components][wc]. This field stores a
* reference to the component implementation. It was inspired by Mozilla's
* [x-tags][] project. Please note: in the future it may be possible to
* `extend Element` from your class, in which case this field will be
* deprecated.
*
* If xtag has not been set, it will simply return `this` [Element].
*
* [wc]: http://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html
* [x-tags]: http://x-tags.org/
*/
// Note: return type is `dynamic` for convenience to suppress warnings when
// members of the component are used. The actual type is a subtype of Element.
get xtag => _xtag != null ? _xtag : this;
set xtag(Element value) {
_xtag = value;
}
@DomName('Element.localName')
@DocsEditable()
@Returns('String')

View file

@ -24,48 +24,6 @@ $!MEMBERS
return _elementFromPoint(x, y);
}
/**
* Checks if the getCssCanvasContext API is supported on the current platform.
*
* See also:
*
* * [getCssCanvasContext]
*/
static bool get supportsCssCanvasContext =>
JS('bool', '!!(document.getCSSCanvasContext)');
/**
* Gets a CanvasRenderingContext which can be used as the CSS background of an
* element.
*
* CSS:
*
* background: -webkit-canvas(backgroundCanvas)
*
* Generate the canvas:
*
* var context = document.getCssCanvasContext('2d', 'backgroundCanvas',
* 100, 100);
* context.fillStyle = 'red';
* context.fillRect(0, 0, 100, 100);
*
* See also:
*
* * [supportsCssCanvasContext]
* * [CanvasElement.getContext]
*/
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental()
@DomName('Document.getCSSCanvasContext')
CanvasRenderingContext getCssCanvasContext(String contextId, String name,
int width, int height) {
if (HtmlDocument.supportsCssCanvasContext)
return JS('CanvasRenderingContext', '#.getCSSCanvasContext(#, #, #, #)', this, contextId, name, width, height);
throw new UnsupportedError("Not supported");
}
@DomName('Document.head')
HeadElement get head => _head;

View file

@ -15,8 +15,6 @@ $!MEMBERS
@DomName('Range.getClientRects')
@DocsEditable()
@Returns('DomRectList|Null')
@Creates('DomRectList')
List<Rectangle> getClientRects() {
var value = _getClientRects();

View file

@ -1,11 +0,0 @@
// Copyright (c) 2012, 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;
@DocsEditable()
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
$!MEMBERS
}