| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 class _ChildrenElementList extends ListBase<Element> | 7 class _ChildrenElementList extends ListBase<Element> |
| 8 implements NodeListWrapper { | 8 implements NodeListWrapper { |
| 9 // Raw Element. | 9 // Raw Element. |
| 10 final Element _element; | 10 final Element _element; |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 * Adds the specified text after the last child of this element. | 720 * Adds the specified text after the last child of this element. |
| 721 */ | 721 */ |
| 722 void appendText(String text) { | 722 void appendText(String text) { |
| 723 this.append(new Text(text)); | 723 this.append(new Text(text)); |
| 724 } | 724 } |
| 725 | 725 |
| 726 /** | 726 /** |
| 727 * Parses the specified text as HTML and adds the resulting node after the | 727 * Parses the specified text as HTML and adds the resulting node after the |
| 728 * last child of this element. | 728 * last child of this element. |
| 729 */ | 729 */ |
| 730 void appendHtml(String text, {NodeValidator validator, | 730 void appendHtml(String text) { |
| 731 NodeTreeSanitizer treeSanitizer}) { | 731 this.insertAdjacentHtml('beforeend', text); |
| 732 this.insertAdjacentHtml('beforeend', text, validator: validator, | |
| 733 treeSanitizer: treeSanitizer); | |
| 734 } | 732 } |
| 735 | 733 |
| 736 /** | 734 /** |
| 737 * Checks to see if the tag name is supported by the current platform. | 735 * Checks to see if the tag name is supported by the current platform. |
| 738 * | 736 * |
| 739 * The tag should be a valid HTML tag name. | 737 * The tag should be a valid HTML tag name. |
| 740 */ | 738 */ |
| 741 static bool isTagSupported(String tag) { | 739 static bool isTagSupported(String tag) { |
| 742 var e = _ElementFactoryProvider.createElement_tag(tag, null); | 740 var e = _ElementFactoryProvider.createElement_tag(tag, null); |
| 743 return e is Element && !(e is UnknownElement); | 741 return e is Element && !(e is UnknownElement); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 void insertAdjacentText(String where, String text) { | 977 void insertAdjacentText(String where, String text) { |
| 980 if (JS('bool', '!!#.insertAdjacentText', this)) { | 978 if (JS('bool', '!!#.insertAdjacentText', this)) { |
| 981 _insertAdjacentText(where, text); | 979 _insertAdjacentText(where, text); |
| 982 } else { | 980 } else { |
| 983 _insertAdjacentNode(where, new Text(text)); | 981 _insertAdjacentNode(where, new Text(text)); |
| 984 } | 982 } |
| 985 } | 983 } |
| 986 | 984 |
| 987 @JSName('insertAdjacentText') | 985 @JSName('insertAdjacentText') |
| 988 void _insertAdjacentText(String where, String text) native; | 986 void _insertAdjacentText(String where, String text) native; |
| 989 | |
| 990 $else | |
| 991 $endif | |
| 992 | 987 |
| 993 /** | 988 /** |
| 994 * Parses text as an HTML fragment and inserts it into the DOM at the | 989 * Parses text as an HTML fragment and inserts it into the DOM at the |
| 995 * specified location. | 990 * specified location. |
| 996 * | 991 * |
| 997 * The [where] parameter indicates where to insert the HTML fragment: | 992 * The [where] parameter indicates where to insert the HTML fragment: |
| 998 * | 993 * |
| 999 * * 'beforeBegin': Immediately before this element. | 994 * * 'beforeBegin': Immediately before this element. |
| 1000 * * 'afterBegin': As the first child of this element. | 995 * * 'afterBegin': As the first child of this element. |
| 1001 * * 'beforeEnd': As the last child of this element. | 996 * * 'beforeEnd': As the last child of this element. |
| 1002 * * 'afterEnd': Immediately after this element. | 997 * * 'afterEnd': Immediately after this element. |
| 1003 * | 998 * |
| 1004 * var html = '<div class="something">content</div>'; | 999 * var html = '<div class="something">content</div>'; |
| 1005 * // Inserts as the first child | 1000 * // Inserts as the first child |
| 1006 * document.body.insertAdjacentHtml('afterBegin', html); | 1001 * document.body.insertAdjacentHtml('afterBegin', html); |
| 1007 * var createdElement = document.body.children[0]; | 1002 * var createdElement = document.body.children[0]; |
| 1008 * print(createdElement.classes[0]); // Prints 'something' | 1003 * print(createdElement.classes[0]); // Prints 'something' |
| 1009 * | 1004 * |
| 1010 * See also: | 1005 * See also: |
| 1011 * | 1006 * |
| 1012 * * [insertAdjacentText] | 1007 * * [insertAdjacentText] |
| 1013 * * [insertAdjacentElement] | 1008 * * [insertAdjacentElement] |
| 1014 */ | 1009 */ |
| 1015 void insertAdjacentHtml(String where, String html, {NodeValidator validator, | 1010 void insertAdjacentHtml(String where, String html) { |
| 1016 NodeTreeSanitizer treeSanitizer}) { | 1011 if (JS('bool', '!!#.insertAdjacentHTML', this)) { |
| 1017 _insertAdjacentNode(where, new DocumentFragment.html(html, | 1012 _insertAdjacentHtml(where, html); |
| 1018 validator: validator, treeSanitizer: treeSanitizer)); | 1013 } else { |
| 1014 _insertAdjacentNode(where, new DocumentFragment.html(html)); |
| 1015 } |
| 1019 } | 1016 } |
| 1020 | 1017 |
| 1021 $if DART2JS | |
| 1022 | |
| 1023 @JSName('insertAdjacentHTML') | 1018 @JSName('insertAdjacentHTML') |
| 1024 void _insertAdjacentHtml(String where, String text) native; | 1019 void _insertAdjacentHtml(String where, String text) native; |
| 1025 | 1020 |
| 1026 /** | 1021 /** |
| 1027 * Inserts [element] into the DOM at the specified location. | 1022 * Inserts [element] into the DOM at the specified location. |
| 1028 * | 1023 * |
| 1029 * To see the possible values for [where], read the doc for | 1024 * To see the possible values for [where], read the doc for |
| 1030 * [insertAdjacentHtml]. | 1025 * [insertAdjacentHtml]. |
| 1031 * | 1026 * |
| 1032 * See also: | 1027 * See also: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1057 case 'beforeend': | 1052 case 'beforeend': |
| 1058 this.append(node); | 1053 this.append(node); |
| 1059 break; | 1054 break; |
| 1060 case 'afterend': | 1055 case 'afterend': |
| 1061 this.parentNode.insertBefore(node, this.nextNode); | 1056 this.parentNode.insertBefore(node, this.nextNode); |
| 1062 break; | 1057 break; |
| 1063 default: | 1058 default: |
| 1064 throw new ArgumentError("Invalid position ${where}"); | 1059 throw new ArgumentError("Invalid position ${where}"); |
| 1065 } | 1060 } |
| 1066 } | 1061 } |
| 1067 $else | |
| 1068 void _insertAdjacentNode(String where, Node node) { | |
| 1069 insertAdjacentElement(where, node); | |
| 1070 } | |
| 1071 $endif | |
| 1072 | 1062 |
| 1073 $if DART2JS | |
| 1074 /** | 1063 /** |
| 1075 * Checks if this element matches the CSS selectors. | 1064 * Checks if this element matches the CSS selectors. |
| 1076 */ | 1065 */ |
| 1077 @Experimental() | 1066 @Experimental() |
| 1078 bool matches(String selectors) { | 1067 bool matches(String selectors) { |
| 1079 if (JS('bool', '!!#.matches', this)) { | 1068 if (JS('bool', '!!#.matches', this)) { |
| 1080 return JS('bool', '#.matches(#)', this, selectors); | 1069 return JS('bool', '#.matches(#)', this, selectors); |
| 1081 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { | 1070 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { |
| 1082 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); | 1071 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); |
| 1083 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { | 1072 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 const ScrollAlignment._internal(this._value); | 1566 const ScrollAlignment._internal(this._value); |
| 1578 toString() => 'ScrollAlignment.$_value'; | 1567 toString() => 'ScrollAlignment.$_value'; |
| 1579 | 1568 |
| 1580 /// Attempt to align the element to the top of the scrollable area. | 1569 /// Attempt to align the element to the top of the scrollable area. |
| 1581 static const TOP = const ScrollAlignment._internal('TOP'); | 1570 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1582 /// Attempt to center the element in the scrollable area. | 1571 /// Attempt to center the element in the scrollable area. |
| 1583 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1572 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1584 /// Attempt to align the element to the bottom of the scrollable area. | 1573 /// Attempt to align the element to the bottom of the scrollable area. |
| 1585 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1574 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1586 } | 1575 } |
| OLD | NEW |