| 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) { | 730 void appendHtml(String text, {NodeValidator validator, |
| 731 this.insertAdjacentHtml('beforeend', text); | 731 NodeTreeSanitizer treeSanitizer}) { |
| 732 this.insertAdjacentHtml('beforeend', text, validator: validator, |
| 733 treeSanitizer: treeSanitizer); |
| 732 } | 734 } |
| 733 | 735 |
| 734 /** | 736 /** |
| 735 * Checks to see if the tag name is supported by the current platform. | 737 * Checks to see if the tag name is supported by the current platform. |
| 736 * | 738 * |
| 737 * The tag should be a valid HTML tag name. | 739 * The tag should be a valid HTML tag name. |
| 738 */ | 740 */ |
| 739 static bool isTagSupported(String tag) { | 741 static bool isTagSupported(String tag) { |
| 740 var e = _ElementFactoryProvider.createElement_tag(tag, null); | 742 var e = _ElementFactoryProvider.createElement_tag(tag, null); |
| 741 return e is Element && !(e is UnknownElement); | 743 return e is Element && !(e is UnknownElement); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 void insertAdjacentText(String where, String text) { | 979 void insertAdjacentText(String where, String text) { |
| 978 if (JS('bool', '!!#.insertAdjacentText', this)) { | 980 if (JS('bool', '!!#.insertAdjacentText', this)) { |
| 979 _insertAdjacentText(where, text); | 981 _insertAdjacentText(where, text); |
| 980 } else { | 982 } else { |
| 981 _insertAdjacentNode(where, new Text(text)); | 983 _insertAdjacentNode(where, new Text(text)); |
| 982 } | 984 } |
| 983 } | 985 } |
| 984 | 986 |
| 985 @JSName('insertAdjacentText') | 987 @JSName('insertAdjacentText') |
| 986 void _insertAdjacentText(String where, String text) native; | 988 void _insertAdjacentText(String where, String text) native; |
| 989 |
| 990 $else |
| 991 $endif |
| 987 | 992 |
| 988 /** | 993 /** |
| 989 * Parses text as an HTML fragment and inserts it into the DOM at the | 994 * Parses text as an HTML fragment and inserts it into the DOM at the |
| 990 * specified location. | 995 * specified location. |
| 991 * | 996 * |
| 992 * The [where] parameter indicates where to insert the HTML fragment: | 997 * The [where] parameter indicates where to insert the HTML fragment: |
| 993 * | 998 * |
| 994 * * 'beforeBegin': Immediately before this element. | 999 * * 'beforeBegin': Immediately before this element. |
| 995 * * 'afterBegin': As the first child of this element. | 1000 * * 'afterBegin': As the first child of this element. |
| 996 * * 'beforeEnd': As the last child of this element. | 1001 * * 'beforeEnd': As the last child of this element. |
| 997 * * 'afterEnd': Immediately after this element. | 1002 * * 'afterEnd': Immediately after this element. |
| 998 * | 1003 * |
| 999 * var html = '<div class="something">content</div>'; | 1004 * var html = '<div class="something">content</div>'; |
| 1000 * // Inserts as the first child | 1005 * // Inserts as the first child |
| 1001 * document.body.insertAdjacentHtml('afterBegin', html); | 1006 * document.body.insertAdjacentHtml('afterBegin', html); |
| 1002 * var createdElement = document.body.children[0]; | 1007 * var createdElement = document.body.children[0]; |
| 1003 * print(createdElement.classes[0]); // Prints 'something' | 1008 * print(createdElement.classes[0]); // Prints 'something' |
| 1004 * | 1009 * |
| 1005 * See also: | 1010 * See also: |
| 1006 * | 1011 * |
| 1007 * * [insertAdjacentText] | 1012 * * [insertAdjacentText] |
| 1008 * * [insertAdjacentElement] | 1013 * * [insertAdjacentElement] |
| 1009 */ | 1014 */ |
| 1010 void insertAdjacentHtml(String where, String html) { | 1015 void insertAdjacentHtml(String where, String html, {NodeValidator validator, |
| 1011 if (JS('bool', '!!#.insertAdjacentHTML', this)) { | 1016 NodeTreeSanitizer treeSanitizer}) { |
| 1012 _insertAdjacentHtml(where, html); | 1017 _insertAdjacentNode(where, new DocumentFragment.html(html, |
| 1013 } else { | 1018 validator: validator, treeSanitizer: treeSanitizer)); |
| 1014 _insertAdjacentNode(where, new DocumentFragment.html(html)); | |
| 1015 } | |
| 1016 } | 1019 } |
| 1017 | 1020 |
| 1021 $if DART2JS |
| 1022 |
| 1018 @JSName('insertAdjacentHTML') | 1023 @JSName('insertAdjacentHTML') |
| 1019 void _insertAdjacentHtml(String where, String text) native; | 1024 void _insertAdjacentHtml(String where, String text) native; |
| 1020 | 1025 |
| 1021 /** | 1026 /** |
| 1022 * Inserts [element] into the DOM at the specified location. | 1027 * Inserts [element] into the DOM at the specified location. |
| 1023 * | 1028 * |
| 1024 * To see the possible values for [where], read the doc for | 1029 * To see the possible values for [where], read the doc for |
| 1025 * [insertAdjacentHtml]. | 1030 * [insertAdjacentHtml]. |
| 1026 * | 1031 * |
| 1027 * See also: | 1032 * See also: |
| 1028 * | 1033 * |
| 1029 * * [insertAdjacentHtml] | 1034 * * [insertAdjacentHtml] |
| 1030 */ | 1035 */ |
| 1031 Element insertAdjacentElement(String where, Element element) { | 1036 Element insertAdjacentElement(String where, Element element) { |
| 1032 if (JS('bool', '!!#.insertAdjacentElement', this)) { | 1037 if (JS('bool', '!!#.insertAdjacentElement', this)) { |
| 1033 _insertAdjacentElement(where, element); | 1038 _insertAdjacentElement(where, element); |
| 1034 } else { | 1039 } else { |
| 1035 _insertAdjacentNode(where, element); | 1040 _insertAdjacentNode(where, element); |
| 1036 } | 1041 } |
| 1037 return element; | 1042 return element; |
| 1038 } | 1043 } |
| 1039 | 1044 |
| 1040 @JSName('insertAdjacentElement') | 1045 @JSName('insertAdjacentElement') |
| 1041 void _insertAdjacentElement(String where, Element element) native; | 1046 void _insertAdjacentElement(String where, Element element) native; |
| 1047 $else |
| 1048 $endif |
| 1042 | 1049 |
| 1043 void _insertAdjacentNode(String where, Node node) { | 1050 void _insertAdjacentNode(String where, Node node) { |
| 1044 switch (where.toLowerCase()) { | 1051 switch (where.toLowerCase()) { |
| 1045 case 'beforebegin': | 1052 case 'beforebegin': |
| 1046 this.parentNode.insertBefore(node, this); | 1053 this.parentNode.insertBefore(node, this); |
| 1047 break; | 1054 break; |
| 1048 case 'afterbegin': | 1055 case 'afterbegin': |
| 1049 var first = this.nodes.length > 0 ? this.nodes[0] : null; | 1056 var first = this.nodes.length > 0 ? this.nodes[0] : null; |
| 1050 this.insertBefore(node, first); | 1057 this.insertBefore(node, first); |
| 1051 break; | 1058 break; |
| 1052 case 'beforeend': | 1059 case 'beforeend': |
| 1053 this.append(node); | 1060 this.append(node); |
| 1054 break; | 1061 break; |
| 1055 case 'afterend': | 1062 case 'afterend': |
| 1056 this.parentNode.insertBefore(node, this.nextNode); | 1063 this.parentNode.insertBefore(node, this.nextNode); |
| 1057 break; | 1064 break; |
| 1058 default: | 1065 default: |
| 1059 throw new ArgumentError("Invalid position ${where}"); | 1066 throw new ArgumentError("Invalid position ${where}"); |
| 1060 } | 1067 } |
| 1061 } | 1068 } |
| 1062 | 1069 |
| 1070 $if DART2JS |
| 1063 /** | 1071 /** |
| 1064 * Checks if this element matches the CSS selectors. | 1072 * Checks if this element matches the CSS selectors. |
| 1065 */ | 1073 */ |
| 1066 @Experimental() | 1074 @Experimental() |
| 1067 bool matches(String selectors) { | 1075 bool matches(String selectors) { |
| 1068 if (JS('bool', '!!#.matches', this)) { | 1076 if (JS('bool', '!!#.matches', this)) { |
| 1069 return JS('bool', '#.matches(#)', this, selectors); | 1077 return JS('bool', '#.matches(#)', this, selectors); |
| 1070 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { | 1078 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { |
| 1071 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); | 1079 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); |
| 1072 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { | 1080 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 const ScrollAlignment._internal(this._value); | 1574 const ScrollAlignment._internal(this._value); |
| 1567 toString() => 'ScrollAlignment.$_value'; | 1575 toString() => 'ScrollAlignment.$_value'; |
| 1568 | 1576 |
| 1569 /// Attempt to align the element to the top of the scrollable area. | 1577 /// Attempt to align the element to the top of the scrollable area. |
| 1570 static const TOP = const ScrollAlignment._internal('TOP'); | 1578 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1571 /// Attempt to center the element in the scrollable area. | 1579 /// Attempt to center the element in the scrollable area. |
| 1572 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1580 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1573 /// Attempt to align the element to the bottom of the scrollable area. | 1581 /// Attempt to align the element to the bottom of the scrollable area. |
| 1574 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1582 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1575 } | 1583 } |
| OLD | NEW |