OLD | NEW |
1 library html; | 1 library html; |
2 | 2 |
3 import 'dart:isolate'; | 3 import 'dart:isolate'; |
4 import 'dart:json'; | 4 import 'dart:json'; |
5 import 'dart:svg' as svg; | 5 import 'dart:svg' as svg; |
6 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 6 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
7 // for details. All rights reserved. Use of this source code is governed by a | 7 // for details. All rights reserved. Use of this source code is governed by a |
8 // BSD-style license that can be found in the LICENSE file. | 8 // BSD-style license that can be found in the LICENSE file. |
9 | 9 |
10 // DO NOT EDIT | 10 // DO NOT EDIT |
(...skipping 6767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6778 | 6778 |
6779 class DocumentFragment extends Node native "*DocumentFragment" { | 6779 class DocumentFragment extends Node native "*DocumentFragment" { |
6780 factory DocumentFragment() => _DocumentFragmentFactoryProvider.createDocumentF
ragment(); | 6780 factory DocumentFragment() => _DocumentFragmentFactoryProvider.createDocumentF
ragment(); |
6781 | 6781 |
6782 factory DocumentFragment.html(String html) => | 6782 factory DocumentFragment.html(String html) => |
6783 _DocumentFragmentFactoryProvider.createDocumentFragment_html(html); | 6783 _DocumentFragmentFactoryProvider.createDocumentFragment_html(html); |
6784 | 6784 |
6785 factory DocumentFragment.svg(String svgContent) => | 6785 factory DocumentFragment.svg(String svgContent) => |
6786 _DocumentFragmentFactoryProvider.createDocumentFragment_svg(svgContent); | 6786 _DocumentFragmentFactoryProvider.createDocumentFragment_svg(svgContent); |
6787 | 6787 |
6788 List<Element> _elements; | 6788 List<Element> get elements => this.children; |
6789 | |
6790 List<Element> get elements { | |
6791 if (_elements == null) { | |
6792 _elements = new FilteredElementList(this); | |
6793 } | |
6794 return _elements; | |
6795 } | |
6796 | 6789 |
6797 // TODO: The type of value should be Collection<Element>. See http://b/5392897 | 6790 // TODO: The type of value should be Collection<Element>. See http://b/5392897 |
6798 void set elements(value) { | 6791 void set elements(value) { |
| 6792 this.children = value; |
| 6793 } |
| 6794 |
| 6795 // Native field is used only by Dart code so does not lead to instantiation |
| 6796 // of native classes |
| 6797 @Creates('Null') |
| 6798 List<Element> _children; |
| 6799 List<Element> get children { |
| 6800 if (_children == null) { |
| 6801 _children = new FilteredElementList(this); |
| 6802 } |
| 6803 return _children; |
| 6804 } |
| 6805 |
| 6806 void set children(Collection<Element> value) { |
6799 // Copy list first since we don't want liveness during iteration. | 6807 // Copy list first since we don't want liveness during iteration. |
6800 List copy = new List.from(value); | 6808 List copy = new List.from(value); |
6801 final elements = this.elements; | 6809 var children = this.children; |
6802 elements.clear(); | 6810 children.clear(); |
6803 elements.addAll(copy); | 6811 children.addAll(copy); |
6804 } | 6812 } |
6805 | 6813 |
6806 Element query(String selectors) => $dom_querySelector(selectors); | 6814 Element query(String selectors) => $dom_querySelector(selectors); |
6807 | 6815 |
6808 List<Element> queryAll(String selectors) => | 6816 List<Element> queryAll(String selectors) => |
6809 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 6817 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
6810 | 6818 |
6811 String get innerHTML { | 6819 String get innerHTML { |
6812 final e = new Element.tag("div"); | 6820 final e = new Element.tag("div"); |
6813 e.nodes.add(this.clone(true)); | 6821 e.nodes.add(this.clone(true)); |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7614 | 7622 |
7615 void set attributes(Map<String, String> value) { | 7623 void set attributes(Map<String, String> value) { |
7616 Map<String, String> attributes = this.attributes; | 7624 Map<String, String> attributes = this.attributes; |
7617 attributes.clear(); | 7625 attributes.clear(); |
7618 for (String key in value.keys) { | 7626 for (String key in value.keys) { |
7619 attributes[key] = value[key]; | 7627 attributes[key] = value[key]; |
7620 } | 7628 } |
7621 } | 7629 } |
7622 | 7630 |
7623 void set elements(Collection<Element> value) { | 7631 void set elements(Collection<Element> value) { |
7624 final elements = this.elements; | 7632 this.children = value; |
7625 elements.clear(); | |
7626 elements.addAll(value); | |
7627 } | 7633 } |
7628 | 7634 |
7629 /** | 7635 /** |
| 7636 * Deprecated, use [children] instead. |
| 7637 */ |
| 7638 List<Element> get elements => this.children; |
| 7639 |
| 7640 /** |
7630 * @domName childElementCount, firstElementChild, lastElementChild, | 7641 * @domName childElementCount, firstElementChild, lastElementChild, |
7631 * children, Node.nodes.add | 7642 * children, Node.nodes.add |
7632 */ | 7643 */ |
7633 List<Element> get elements => new _ChildrenElementList._wrap(this); | 7644 List<Element> get children => new _ChildrenElementList._wrap(this); |
| 7645 |
| 7646 void set children(Collection<Element> value) { |
| 7647 // Copy list first since we don't want liveness during iteration. |
| 7648 List copy = new List.from(value); |
| 7649 var children = this.children; |
| 7650 children.clear(); |
| 7651 children.addAll(copy); |
| 7652 } |
7634 | 7653 |
7635 Element query(String selectors) => $dom_querySelector(selectors); | 7654 Element query(String selectors) => $dom_querySelector(selectors); |
7636 | 7655 |
7637 List<Element> queryAll(String selectors) => | 7656 List<Element> queryAll(String selectors) => |
7638 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); | 7657 new _FrozenElementList._wrap($dom_querySelectorAll(selectors)); |
7639 | 7658 |
7640 /** @domName className, classList */ | 7659 /** @domName className, classList */ |
7641 CssClassSet get classes => new _ElementCssClassSet(this); | 7660 CssClassSet get classes => new _ElementCssClassSet(this); |
7642 | 7661 |
7643 void set classes(Collection<String> value) { | 7662 void set classes(Collection<String> value) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7977 if (match != null) { | 7996 if (match != null) { |
7978 tag = match.group(1).toLowerCase(); | 7997 tag = match.group(1).toLowerCase(); |
7979 if (_CUSTOM_PARENT_TAG_MAP.containsKey(tag)) { | 7998 if (_CUSTOM_PARENT_TAG_MAP.containsKey(tag)) { |
7980 parentTag = _CUSTOM_PARENT_TAG_MAP[tag]; | 7999 parentTag = _CUSTOM_PARENT_TAG_MAP[tag]; |
7981 } | 8000 } |
7982 } | 8001 } |
7983 final Element temp = new Element.tag(parentTag); | 8002 final Element temp = new Element.tag(parentTag); |
7984 temp.innerHTML = html; | 8003 temp.innerHTML = html; |
7985 | 8004 |
7986 Element element; | 8005 Element element; |
7987 if (temp.elements.length == 1) { | 8006 if (temp.children.length == 1) { |
7988 element = temp.elements[0]; | 8007 element = temp.children[0]; |
7989 } else if (parentTag == 'html' && temp.elements.length == 2) { | 8008 } else if (parentTag == 'html' && temp.children.length == 2) { |
7990 // Work around for edge case in WebKit and possibly other browsers where | 8009 // Work around for edge case in WebKit and possibly other browsers where |
7991 // both body and head elements are created even though the inner html | 8010 // both body and head elements are created even though the inner html |
7992 // only contains a head or body element. | 8011 // only contains a head or body element. |
7993 element = temp.elements[tag == 'head' ? 0 : 1]; | 8012 element = temp.children[tag == 'head' ? 0 : 1]; |
7994 } else { | 8013 } else { |
7995 throw new ArgumentError('HTML had ${temp.elements.length} ' | 8014 throw new ArgumentError('HTML had ${temp.children.length} ' |
7996 'top level elements but 1 expected'); | 8015 'top level elements but 1 expected'); |
7997 } | 8016 } |
7998 element.remove(); | 8017 element.remove(); |
7999 return element; | 8018 return element; |
8000 } | 8019 } |
8001 | 8020 |
8002 /** @domName Document.createElement */ | 8021 /** @domName Document.createElement */ |
8003 // Optimization to improve performance until the dart2js compiler inlines this | 8022 // Optimization to improve performance until the dart2js compiler inlines this |
8004 // method. | 8023 // method. |
8005 static Element createElement_tag(String tag) => | 8024 static Element createElement_tag(String tag) => |
(...skipping 16985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24991 if (length < 0) throw new ArgumentError('length'); | 25010 if (length < 0) throw new ArgumentError('length'); |
24992 if (start < 0) throw new RangeError.value(start); | 25011 if (start < 0) throw new RangeError.value(start); |
24993 int end = start + length; | 25012 int end = start + length; |
24994 if (end > a.length) throw new RangeError.value(end); | 25013 if (end > a.length) throw new RangeError.value(end); |
24995 for (int i = start; i < end; i++) { | 25014 for (int i = start; i < end; i++) { |
24996 accumulator.add(a[i]); | 25015 accumulator.add(a[i]); |
24997 } | 25016 } |
24998 return accumulator; | 25017 return accumulator; |
24999 } | 25018 } |
25000 } | 25019 } |
OLD | NEW |