W3cubDocs

/Dart 2

SvgElement.svg constructor

SvgElement.svg(String svg, { NodeValidator validator, NodeTreeSanitizer treeSanitizer })

Implementation

factory SvgElement.svg(String svg,
    {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) {
  if (validator == null && treeSanitizer == null) {
    validator = new NodeValidatorBuilder.common()..allowSvg();
  }

  final match = _START_TAG_REGEXP.firstMatch(svg);
  var parentElement;
  if (match != null && match.group(1).toLowerCase() == 'svg') {
    parentElement = document.body;
  } else {
    parentElement = new SvgSvgElement();
  }
  var fragment = parentElement.createFragment(svg,
      validator: validator, treeSanitizer: treeSanitizer);
  return fragment.nodes.where((e) => e is SvgElement).single;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-svg/SvgElement/SvgElement.svg.html