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

Unified Diff: sdk/lib/html/src/shared_SVGFactoryProviders.dart

Issue 11398002: Splitting SVG types out of dart:html. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minifying. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/src/shared_FactoryProviders.dart ('k') | sdk/lib/html/templates/dart2js_impl.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/src/shared_SVGFactoryProviders.dart
diff --git a/sdk/lib/html/src/shared_SVGFactoryProviders.dart b/sdk/lib/html/src/shared_SVGFactoryProviders.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5fa3b4593b5ae324c07935579306268f5a7b5807
--- /dev/null
+++ b/sdk/lib/html/src/shared_SVGFactoryProviders.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+part of svg;
+
+final _START_TAG_REGEXP = const RegExp('<(\\w+)');
+
+class _SVGElementFactoryProvider {
+ static SVGElement createSVGElement_tag(String tag) {
+ final Element temp =
+ document.$dom_createElementNS("http://www.w3.org/2000/svg", tag);
+ return temp;
+ }
+
+ static SVGElement createSVGElement_svg(String svg) {
+ Element parentTag;
+ final match = _START_TAG_REGEXP.firstMatch(svg);
+ if (match != null && match.group(1).toLowerCase() == 'svg') {
+ parentTag = new Element.tag('div');
+ } else {
+ parentTag = new SVGSVGElement();
+ }
+
+ parentTag.innerHTML = svg;
+ if (parentTag.elements.length == 1) return parentTag.elements.removeLast();
+
+ throw new ArgumentError(
+ 'SVG had ${parentTag.elements.length} '
+ 'top-level elements but 1 expected');
+ }
+}
+
+class _SVGSVGElementFactoryProvider {
+ static SVGSVGElement createSVGSVGElement() {
+ final el = new SVGElement.tag("svg");
+ // The SVG spec requires the version attribute to match the spec version
+ el.attributes['version'] = "1.1";
+ return el;
+ }
+}
« no previous file with comments | « sdk/lib/html/src/shared_FactoryProviders.dart ('k') | sdk/lib/html/templates/dart2js_impl.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698