Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: client/html/src/SVGElementWrappingImplementation.dart

Issue 9392028: Ensure that newly-constructed elements don't have parents. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 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) {
(...skipping 11 matching lines...) Expand all
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.nodes.removeLast();
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698