adjustForeignAttributes method

void adjustForeignAttributes(
  1. StartTagToken token
)

Implementation

void adjustForeignAttributes(StartTagToken token) {
  // TODO(jmesserly): I don't like mixing non-string objects with strings in
  // the Node.attributes Map. Is there another solution?
  final replacements = const {
    'xlink:actuate': AttributeName('xlink', 'actuate', Namespaces.xlink),
    'xlink:arcrole': AttributeName('xlink', 'arcrole', Namespaces.xlink),
    'xlink:href': AttributeName('xlink', 'href', Namespaces.xlink),
    'xlink:role': AttributeName('xlink', 'role', Namespaces.xlink),
    'xlink:show': AttributeName('xlink', 'show', Namespaces.xlink),
    'xlink:title': AttributeName('xlink', 'title', Namespaces.xlink),
    'xlink:type': AttributeName('xlink', 'type', Namespaces.xlink),
    'xml:base': AttributeName('xml', 'base', Namespaces.xml),
    'xml:lang': AttributeName('xml', 'lang', Namespaces.xml),
    'xml:space': AttributeName('xml', 'space', Namespaces.xml),
    'xmlns': AttributeName(null, 'xmlns', Namespaces.xmlns),
    'xmlns:xlink': AttributeName('xmlns', 'xlink', Namespaces.xmlns)
  };

  for (var originalName in token.data.keys.toList(growable: false)) {
    final foreignName = replacements[originalName as String];
    if (foreignName != null) {
      token.data[foreignName] = token.data.remove(originalName)!;
    }
  }
}