OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 _AttributeClassSet extends CssClassSet { | 7 class _AttributeClassSet extends CssClassSet { |
8 final Element _element; | 8 final Element _element; |
9 | 9 |
10 _AttributeClassSet(this._element); | 10 _AttributeClassSet(this._element); |
11 | 11 |
12 Set<String> readClasses() { | 12 Set<String> readClasses() { |
13 var classname = _element.attributes['class']; | 13 var classname = _element.attributes['class']; |
14 | 14 |
15 Set<String> s = new Set<String>(); | 15 Set<String> s = new Set<String>(); |
16 if (classname == null) { | 16 if (classname == null) { |
17 return s; | 17 return s; |
18 } | 18 } |
19 for (String name in classname.split(' ')) { | 19 for (String name in classname.split(' ')) { |
20 String trimmed = name.trim(); | 20 String trimmed = name.trim(); |
21 if (!trimmed.isEmpty) { | 21 if (!trimmed.isEmpty) { |
22 s.add(trimmed); | 22 s.add(trimmed); |
23 } | 23 } |
24 } | 24 } |
25 return s; | 25 return s; |
26 } | 26 } |
27 | 27 |
28 void writeClasses(Set s) { | 28 void writeClasses(Set s) { |
29 List list = new List.from(s); | 29 _element.attributes['class'] = s.join(' '); |
30 _element.attributes['class'] = Strings.join(list, ' '); | |
31 } | 30 } |
32 } | 31 } |
33 | 32 |
34 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 33 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
35 factory $CLASSNAME.tag(String tag) => | 34 factory $CLASSNAME.tag(String tag) => |
36 _$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_tag(tag); | 35 _$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_tag(tag); |
37 factory $CLASSNAME.svg(String svg) => | 36 factory $CLASSNAME.svg(String svg) => |
38 _$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_svg(svg); | 37 _$(CLASSNAME)FactoryProvider.create$(CLASSNAME)_svg(svg); |
39 | 38 |
40 _AttributeClassSet _cssClassSet; | 39 _AttributeClassSet _cssClassSet; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 * Checks to see if the SVG element type is supported by the current platform. | 104 * Checks to see if the SVG element type is supported by the current platform. |
106 * | 105 * |
107 * The tag should be a valid SVG element tag name. | 106 * The tag should be a valid SVG element tag name. |
108 */ | 107 */ |
109 static bool isTagSupported(String tag) { | 108 static bool isTagSupported(String tag) { |
110 var e = new $CLASSNAME.tag(tag); | 109 var e = new $CLASSNAME.tag(tag); |
111 return e is $CLASSNAME && !(e is UnknownElement); | 110 return e is $CLASSNAME && !(e is UnknownElement); |
112 } | 111 } |
113 $!MEMBERS | 112 $!MEMBERS |
114 } | 113 } |
OLD | NEW |