| 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] | |
| 905 */ | 898 */ |
| 906 @SupportedBrowser(SupportedBrowser.CHROME) | |
| 907 @SupportedBrowser(SupportedBrowser.FIREFOX) | |
| 908 @SupportedBrowser(SupportedBrowser.IE, '10') | |
| 909 @SupportedBrowser(SupportedBrowser.SAFARI) | |
| 910 @Experimental | 899 @Experimental |
| 911 bool matches(String selectors) { | 900 bool matches(String selectors) { |
| 912 if (JS('bool', '!!#.matches', this)) { | 901 if (JS('bool', '!!#.matches', this)) { |
| 913 return JS('bool', '#.matches(#)', this, selectors); | 902 return JS('bool', '#.matches(#)', this, selectors); |
| 914 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { | 903 } else if (JS('bool', '!!#.webkitMatchesSelector', this)) { |
| 915 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); | 904 return JS('bool', '#.webkitMatchesSelector(#)', this, selectors); |
| 916 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { | 905 } else if (JS('bool', '!!#.mozMatchesSelector', this)) { |
| 917 return JS('bool', '#.mozMatchesSelector(#)', this, selectors); | 906 return JS('bool', '#.mozMatchesSelector(#)', this, selectors); |
| 918 } else if (JS('bool', '!!#.msMatchesSelector', this)) { | 907 } else if (JS('bool', '!!#.msMatchesSelector', this)) { |
| 919 return JS('bool', '#.msMatchesSelector(#)', this, selectors); | 908 return JS('bool', '#.msMatchesSelector(#)', this, selectors); |
| 920 } | 909 } |
| 921 throw new UnsupportedError("Not supported on this platform"); | 910 throw new UnsupportedError("Not supported on this platform"); |
| 922 } | 911 } |
| 923 | |
| 924 /** | |
| 925 * Checks if the matches function is supported on the current platform. | |
| 926 * | |
| 927 * See also: | |
| 928 * | |
| 929 * * [matches] | |
| 930 */ | |
| 931 static bool get supportsMatches { | |
| 932 var e = new DivElement(); | |
| 933 return JS('bool', '!!(#.matches || #.webkitMatchesSelector || ' | |
| 934 '#.mozMatchesSelector || #.msMatchesSelector)', e, e, e, e); | |
| 935 } | |
| 936 $else | 912 $else |
| 937 /** | |
| 938 * Checks if the matches function is supported on the current platform. | |
| 939 * | |
| 940 * See also: | |
| 941 * | |
| 942 * * [matches] | |
| 943 */ | |
| 944 static bool get supportsMatches => true; | |
| 945 $endif | 913 $endif |
| 946 | 914 |
| 947 $!MEMBERS | 915 $!MEMBERS |
| 948 } | 916 } |
| 949 | 917 |
| 950 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | 918 final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
| 951 class _ElementFactoryProvider { | 919 class _ElementFactoryProvider { |
| 952 static const _CUSTOM_PARENT_TAG_MAP = const { | 920 static const _CUSTOM_PARENT_TAG_MAP = const { |
| 953 'body' : 'html', | 921 'body' : 'html', |
| 954 'head' : 'html', | 922 'head' : 'html', |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 $if DART2JS | 1045 $if DART2JS |
| 1078 // Optimization to improve performance until the dart2js compiler inlines this | 1046 // Optimization to improve performance until the dart2js compiler inlines this |
| 1079 // method. | 1047 // method. |
| 1080 static dynamic createElement_tag(String tag) => | 1048 static dynamic createElement_tag(String tag) => |
| 1081 JS('Element', 'document.createElement(#)', tag); | 1049 JS('Element', 'document.createElement(#)', tag); |
| 1082 $else | 1050 $else |
| 1083 static Element createElement_tag(String tag) => | 1051 static Element createElement_tag(String tag) => |
| 1084 document.$dom_createElement(tag); | 1052 document.$dom_createElement(tag); |
| 1085 $endif | 1053 $endif |
| 1086 } | 1054 } |
| OLD | NEW |