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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 'td': 'tr', | 850 'td': 'tr', |
851 'colgroup': 'table', | 851 'colgroup': 'table', |
852 'col' : 'colgroup', | 852 'col' : 'colgroup', |
853 'tr' : 'tbody', | 853 'tr' : 'tbody', |
854 'tbody' : 'table', | 854 'tbody' : 'table', |
855 'tfoot' : 'table', | 855 'tfoot' : 'table', |
856 'thead' : 'table', | 856 'thead' : 'table', |
857 'track' : 'audio', | 857 'track' : 'audio', |
858 }; | 858 }; |
859 | 859 |
860 /** @domName Document.createElement */ | 860 @DomName('Document.createElement') |
861 static Element createElement_html(String html) { | 861 static Element createElement_html(String html) { |
862 // TODO(jacobr): this method can be made more robust and performant. | 862 // TODO(jacobr): this method can be made more robust and performant. |
863 // 1) Cache the dummy parent elements required to use innerHTML rather than | 863 // 1) Cache the dummy parent elements required to use innerHTML rather than |
864 // creating them every call. | 864 // creating them every call. |
865 // 2) Verify that the html does not contain leading or trailing text nodes. | 865 // 2) Verify that the html does not contain leading or trailing text nodes. |
866 // 3) Verify that the html does not contain both <head> and <body> tags. | 866 // 3) Verify that the html does not contain both <head> and <body> tags. |
867 // 4) Detatch the created element from its dummy parent. | 867 // 4) Detatch the created element from its dummy parent. |
868 String parentTag = 'div'; | 868 String parentTag = 'div'; |
869 String tag; | 869 String tag; |
870 final match = _START_TAG_REGEXP.firstMatch(html); | 870 final match = _START_TAG_REGEXP.firstMatch(html); |
(...skipping 15 matching lines...) Expand all Loading... |
886 // only contains a head or body element. | 886 // only contains a head or body element. |
887 element = temp.children[tag == 'head' ? 0 : 1]; | 887 element = temp.children[tag == 'head' ? 0 : 1]; |
888 } else { | 888 } else { |
889 throw new ArgumentError('HTML had ${temp.children.length} ' | 889 throw new ArgumentError('HTML had ${temp.children.length} ' |
890 'top level elements but 1 expected'); | 890 'top level elements but 1 expected'); |
891 } | 891 } |
892 element.remove(); | 892 element.remove(); |
893 return element; | 893 return element; |
894 } | 894 } |
895 | 895 |
896 /** @domName Document.createElement */ | 896 @DomName('Document.createElement') |
897 $if DART2JS | 897 $if DART2JS |
898 // Optimization to improve performance until the dart2js compiler inlines this | 898 // Optimization to improve performance until the dart2js compiler inlines this |
899 // method. | 899 // method. |
900 static dynamic createElement_tag(String tag) => | 900 static dynamic createElement_tag(String tag) => |
901 JS('Element', 'document.createElement(#)', tag); | 901 JS('Element', 'document.createElement(#)', tag); |
902 $else | 902 $else |
903 static Element createElement_tag(String tag) => | 903 static Element createElement_tag(String tag) => |
904 document.$dom_createElement(tag); | 904 document.$dom_createElement(tag); |
905 $endif | 905 $endif |
906 } | 906 } |
OLD | NEW |