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 CssClassSetImpl { | 7 class AttributeClassSet extends CssClassSetImpl { |
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 if (classname is AnimatedString) { |
| 15 classname = classname.baseVal; |
| 16 } |
14 | 17 |
15 Set<String> s = new LinkedHashSet<String>(); | 18 Set<String> s = new LinkedHashSet<String>(); |
16 if (classname == null) { | 19 if (classname == null) { |
17 return s; | 20 return s; |
18 } | 21 } |
19 for (String name in classname.split(' ')) { | 22 for (String name in classname.split(' ')) { |
20 String trimmed = name.trim(); | 23 String trimmed = name.trim(); |
21 if (!trimmed.isEmpty) { | 24 if (!trimmed.isEmpty) { |
22 s.add(trimmed); | 25 s.add(trimmed); |
23 } | 26 } |
24 } | 27 } |
25 return s; | 28 return s; |
26 } | 29 } |
27 | 30 |
28 void writeClasses(Set s) { | 31 void writeClasses(Set s) { |
29 _element.attributes['class'] = s.join(' '); | 32 _element.setAttribute('class', s.join(' ')); |
30 } | 33 } |
31 } | 34 } |
32 | 35 |
33 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 36 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
34 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); | 37 static final _START_TAG_REGEXP = new RegExp('<(\\w+)'); |
35 | 38 |
36 factory $CLASSNAME.tag(String tag) => | 39 factory $CLASSNAME.tag(String tag) => |
37 document.createElementNS("http://www.w3.org/2000/svg", tag); | 40 document.createElementNS("http://www.w3.org/2000/svg", tag); |
38 factory $CLASSNAME.svg(String svg, | 41 factory $CLASSNAME.svg(String svg, |
39 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 42 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
40 | 43 |
41 if (validator == null && treeSanitizer == null) { | 44 if (validator == null && treeSanitizer == null) { |
42 validator = new NodeValidatorBuilder.common()..allowSvg(); | 45 validator = new NodeValidatorBuilder.common()..allowSvg(); |
43 } | 46 } |
44 | 47 |
45 final match = _START_TAG_REGEXP.firstMatch(svg); | 48 final match = _START_TAG_REGEXP.firstMatch(svg); |
46 var parentElement; | 49 var parentElement; |
47 if (match != null && match.group(1).toLowerCase() == 'svg') { | 50 if (match != null && match.group(1).toLowerCase() == 'svg') { |
48 parentElement = document.body; | 51 parentElement = document.body; |
49 } else { | 52 } else { |
50 parentElement = new SvgSvgElement(); | 53 parentElement = new SvgSvgElement(); |
51 } | 54 } |
52 var fragment = parentElement.createFragment(svg, validator: validator, | 55 var fragment = parentElement.createFragment(svg, validator: validator, |
53 treeSanitizer: treeSanitizer); | 56 treeSanitizer: treeSanitizer); |
54 return fragment.nodes.where((e) => e is SvgElement).single; | 57 return fragment.nodes.where((e) => e is SvgElement).single; |
55 } | 58 } |
56 | 59 |
57 CssClassSet get classes => new _AttributeClassSet(this); | 60 CssClassSet get classes => new AttributeClassSet(this); |
58 | 61 |
59 List<Element> get children => new FilteredElementList(this); | 62 List<Element> get children => new FilteredElementList(this); |
60 | 63 |
61 set children(List<Element> value) { | 64 set children(List<Element> value) { |
62 final children = this.children; | 65 final children = this.children; |
63 children.clear(); | 66 children.clear(); |
64 children.addAll(value); | 67 children.addAll(value); |
65 } | 68 } |
66 | 69 |
67 String get outerHtml { | 70 String get outerHtml { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return e is $CLASSNAME && !(e is UnknownElement); | 147 return e is $CLASSNAME && !(e is UnknownElement); |
145 } | 148 } |
146 | 149 |
147 $if JSINTEROP | 150 $if JSINTEROP |
148 set _svgClassName(AnimatedString value) => | 151 set _svgClassName(AnimatedString value) => |
149 _blink.BlinkSVGElement.instance.className_Setter_(this, value); | 152 _blink.BlinkSVGElement.instance.className_Setter_(this, value); |
150 | 153 |
151 $endif | 154 $endif |
152 $!MEMBERS | 155 $!MEMBERS |
153 } | 156 } |
OLD | NEW |