OLD | NEW |
---|---|
1 // Copyright (c) 2011, 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 class _SVGClassSet extends _CssClassSet { | 5 class _SVGClassSet extends _CssClassSet { |
6 _SVGClassSet(element) : super(element); | 6 _SVGClassSet(element) : super(element); |
7 | 7 |
8 String _className() => _element.className.baseVal; | 8 String _className() => _element.className.baseVal; |
9 | 9 |
10 void _write(Set s) { | 10 void _write(Set s) { |
11 _element.className.baseVal = _formatSet(s); | 11 _element.className.baseVal = _formatSet(s); |
(...skipping 10 matching lines...) Expand all Loading... | |
22 factory SVGElementWrappingImplementation.svg(String svg) { | 22 factory SVGElementWrappingImplementation.svg(String svg) { |
23 Element parentTag; | 23 Element parentTag; |
24 final match = _START_TAG_REGEXP.firstMatch(svg); | 24 final match = _START_TAG_REGEXP.firstMatch(svg); |
25 if (match != null && match.group(1).toLowerCase() == 'svg') { | 25 if (match != null && match.group(1).toLowerCase() == 'svg') { |
26 parentTag = new Element.tag('div'); | 26 parentTag = new Element.tag('div'); |
27 } else { | 27 } else { |
28 parentTag = new SVGSVGElement(); | 28 parentTag = new SVGSVGElement(); |
29 } | 29 } |
30 | 30 |
31 parentTag.innerHTML = svg; | 31 parentTag.innerHTML = svg; |
32 if (parentTag.elements.length == 1) return parentTag.elements[0]; | 32 if (parentTag.elements.length == 1) return parentTag.elements.iterator().nex t(); |
nweiz
2012/02/02 19:01:11
Line length.
Why doesn't [0] work? Or #first?
zundel
2012/03/06 20:16:44
Because I didn't really fix the problem. I've fix
| |
33 | 33 |
34 throw new IllegalArgumentException('SVG had ${parentTag.elements.length} ' + | 34 throw new IllegalArgumentException('SVG had ${parentTag.elements.length} ' + |
35 'top-level elements but 1 expected'); | 35 'top-level elements but 1 expected'); |
36 } | 36 } |
37 | 37 |
38 Set<String> get classes() { | 38 Set<String> get classes() { |
39 if (_cssClassSet === null) { | 39 if (_cssClassSet === null) { |
40 _cssClassSet = new _SVGClassSet(_ptr); | 40 _cssClassSet = new _SVGClassSet(_ptr); |
41 } | 41 } |
42 return _cssClassSet; | 42 return _cssClassSet; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 void set innerHTML(String svg) { | 83 void set innerHTML(String svg) { |
84 var container = new Element.tag("div"); | 84 var container = new Element.tag("div"); |
85 // Wrap the SVG string in <svg> so that SVGElements are created, rather than | 85 // Wrap the SVG string in <svg> so that SVGElements are created, rather than |
86 // HTMLElements. | 86 // HTMLElements. |
87 container.innerHTML = '<svg version="1.1">$svg</svg>'; | 87 container.innerHTML = '<svg version="1.1">$svg</svg>'; |
88 this.elements = container.elements.first.elements; | 88 this.elements = container.elements.first.elements; |
89 } | 89 } |
90 | 90 |
91 SVGElement clone(bool deep) => super.clone(deep); | 91 SVGElement clone(bool deep) => super.clone(deep); |
92 } | 92 } |
OLD | NEW |