| 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 html; | 5 part of html; |
| 6 | 6 |
| 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated | 7 // TODO(jacobr): use _Lists.dart to remove some of the duplicated |
| 8 // functionality. | 8 // functionality. |
| 9 class _ChildrenElementList implements List { | 9 class _ChildrenElementList implements List { |
| 10 // Raw Element. | 10 // Raw Element. |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 case 'afterend': | 888 case 'afterend': |
| 889 this.parentNode.insertBefore(node, this.nextNode); | 889 this.parentNode.insertBefore(node, this.nextNode); |
| 890 break; | 890 break; |
| 891 default: | 891 default: |
| 892 throw new ArgumentError("Invalid position ${where}"); | 892 throw new ArgumentError("Invalid position ${where}"); |
| 893 } | 893 } |
| 894 } | 894 } |
| 895 | 895 |
| 896 /** | 896 /** |
| 897 * Checks if this element matches the CSS selectors. | 897 * Checks if this element matches the CSS selectors. |
| 898 * |
| 899 * Use [supportsMatches] to check if this is supported on the current |
| 900 * platform. |
| 901 * |
| 902 * See also: |
| 903 * |
| 904 * * [supportsMatches] |
| 898 */ | 905 */ |
| 906 @SupportedBrowser(SupportedBrowser.CHROME) |
| 907 @SupportedBrowser(SupportedBrowser.FIREFOX) |
| 908 @SupportedBrowser(SupportedBrowser.IE, '10') |
| 909 @SupportedBrowser(SupportedBrowser.SAFARI) |
| 899 @Experimental | 910 @Experimental |
| 900 bool matches(String selectors) { | 911 bool matches(String selectors) { |
| 901 if (JS('bool', '!!#.matches', this)) { | 912 if (JS('bool', '!!#.matches', this)) { |
| 902 return JS('bool', '#.matches(#)', this, selectors); | 913 return JS('bool', '#.matches(#)', this, selectors); |
| 903 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { | 914 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { |
| 904 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); | 915 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); |
| 905 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { | 916 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { |
| 906 return JS('bool', '#.mozMatchesSelector(#)', this, selectors); | 917 return JS('bool', '#.mozMatchesSelector(#)', this, selectors); |
| 907 } else if (JS('bool', '!!#.msMatchesSelector', this)) { | 918 } else if (JS('bool', '!!#.msMatchesSelector', this)) { |
| 908 return JS('bool', '#.msMatchesSelector(#)', this, selectors); | 919 return JS('bool', '#.msMatchesSelector(#)', this, selectors); |
| 909 } | 920 } |
| 910 } | 921 } |
| 922 |
| 923 /** |
| 924 * Checks if the matches function is supported on the current platform. |
| 925 * |
| 926 * See also: |
| 927 * |
| 928 * * [matches] |
| 929 */ |
| 930 static bool get supportsMatches { |
| 931 var e = new DivElement(); |
| 932 return JS('bool', '!!(#.matches || #.webkitMatchesSelector || ' |
| 933 '#.mozMatchesSelector || #.msMatchesSelector)', e, e, e, e); |
| 934 } |
| 911 $else | 935 $else |
| 936 /** |
| 937 * Checks if the matches function is supported on the current platform. |
| 938 * |
| 939 * See also: |
| 940 * |
| 941 * * [matches] |
| 942 */ |
| 943 static bool get supportsMatches => true; |
| 912 $endif | 944 $endif |
| 913 | 945 |
| 914 $!MEMBERS | 946 $!MEMBERS |
| 915 } | 947 } |
| 916 | 948 |
| 917 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | 949 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 918 class _ElementFactoryProvider { | 950 class _ElementFactoryProvider { |
| 919 static const _CUSTOM_PARENT_TAG_MAP = const { | 951 static const _CUSTOM_PARENT_TAG_MAP = const { |
| 920 'body' : 'html', | 952 'body' : 'html', |
| 921 'head' : 'html', | 953 'head' : 'html', |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 $if DART2JS | 1076 $if DART2JS |
| 1045 // Optimization to improve performance until the dart2js compiler inlines this | 1077 // Optimization to improve performance until the dart2js compiler inlines this |
| 1046 // method. | 1078 // method. |
| 1047 static dynamic createElement_tag(String tag) => | 1079 static dynamic createElement_tag(String tag) => |
| 1048 JS('Element', 'document.createElement(#)', tag); | 1080 JS('Element', 'document.createElement(#)', tag); |
| 1049 $else | 1081 $else |
| 1050 static Element createElement_tag(String tag) => | 1082 static Element createElement_tag(String tag) => |
| 1051 document.$dom_createElement(tag); | 1083 document.$dom_createElement(tag); |
| 1052 $endif | 1084 $endif |
| 1053 } | 1085 } |
| OLD | NEW |