fix(render): create svg elements with the right namespace
Temporary fix for #4506 Closes #4949
This commit is contained in:
@ -215,6 +215,10 @@ abstract class AbstractHtml5LibAdapter implements DomAdapter {
|
||||
return new Element.tag(tagName);
|
||||
}
|
||||
|
||||
createElementNS(ns, tagName, [doc]) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
createTextNode(String text, [doc]) => new Text(text);
|
||||
|
||||
createScriptTag(String attrName, String attrValue, [doc]) {
|
||||
@ -297,6 +301,10 @@ abstract class AbstractHtml5LibAdapter implements DomAdapter {
|
||||
element.attributes[name] = value;
|
||||
}
|
||||
|
||||
setAttributeNS(element, String ns, String name, String value) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
|
||||
removeAttribute(element, String attribute) {
|
||||
element.attributes.remove(attribute);
|
||||
}
|
||||
|
@ -287,6 +287,11 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
return doc.createElement(tagName);
|
||||
}
|
||||
|
||||
Element createElementNS(String ns, String tagName, [HtmlDocument doc = null]) {
|
||||
if (doc == null) doc = document;
|
||||
return doc.createElementNS(ns, tagName);
|
||||
}
|
||||
|
||||
Text createTextNode(String text, [HtmlDocument doc = null]) {
|
||||
return new Text(text);
|
||||
}
|
||||
@ -354,6 +359,10 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
element.setAttribute(name, value);
|
||||
}
|
||||
|
||||
void setAttributeNS(Element element, String ns, String name, String value) {
|
||||
element.setAttributeNS(ns, name, value);
|
||||
}
|
||||
|
||||
void removeAttribute(Element element, String name) {
|
||||
//there is no removeAttribute method as of now in Dart:
|
||||
//https://code.google.com/p/dart/issues/detail?id=19934
|
||||
|
@ -182,6 +182,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
return t;
|
||||
}
|
||||
createElement(tagName, doc = document): HTMLElement { return doc.createElement(tagName); }
|
||||
createElementNS(ns, tagName, doc = document): Element { return doc.createElementNS(ns, tagName); }
|
||||
createTextNode(text: string, doc = document): Text { return doc.createTextNode(text); }
|
||||
createScriptTag(attrName: string, attrValue: string, doc = document): HTMLScriptElement {
|
||||
var el = <HTMLScriptElement>doc.createElement('SCRIPT');
|
||||
@ -225,6 +226,9 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
hasAttribute(element, attribute: string): boolean { return element.hasAttribute(attribute); }
|
||||
getAttribute(element, attribute: string): string { return element.getAttribute(attribute); }
|
||||
setAttribute(element, name: string, value: string) { element.setAttribute(name, value); }
|
||||
setAttributeNS(ns: string, element, name: string, value: string) {
|
||||
element.setAttributeNS(ns, name, value);
|
||||
}
|
||||
removeAttribute(element, attribute: string) { element.removeAttribute(attribute); }
|
||||
templateAwareRoot(el): any { return this.isTemplateElement(el) ? this.content(el) : el; }
|
||||
createHtmlDocument(): HTMLDocument {
|
||||
|
@ -71,6 +71,7 @@ export abstract class DomAdapter {
|
||||
abstract createComment(text: string): any;
|
||||
abstract createTemplate(html): HTMLElement;
|
||||
abstract createElement(tagName, doc?): HTMLElement;
|
||||
abstract createElementNS(ns: string, tagName: string, doc?): Element;
|
||||
abstract createTextNode(text: string, doc?): Text;
|
||||
abstract createScriptTag(attrName: string, attrValue: string, doc?): HTMLElement;
|
||||
abstract createStyleElement(css: string, doc?): HTMLStyleElement;
|
||||
@ -93,6 +94,7 @@ export abstract class DomAdapter {
|
||||
abstract hasAttribute(element, attribute: string): boolean;
|
||||
abstract getAttribute(element, attribute: string): string;
|
||||
abstract setAttribute(element, name: string, value: string);
|
||||
abstract setAttributeNS(element, ns: string, name: string, value: string);
|
||||
abstract removeAttribute(element, attribute: string);
|
||||
abstract templateAwareRoot(el);
|
||||
abstract createHtmlDocument(): HTMLDocument;
|
||||
|
@ -276,6 +276,7 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||
createElement(tagName): HTMLElement {
|
||||
return treeAdapter.createElement(tagName, 'http://www.w3.org/1999/xhtml', []);
|
||||
}
|
||||
createElementNS(ns, tagName): HTMLElement { throw 'not implemented'; }
|
||||
createTextNode(text: string): Text {
|
||||
var t = <any>this.createComment(text);
|
||||
t.type = 'text';
|
||||
@ -435,6 +436,7 @@ export class Parse5DomAdapter extends DomAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
setAttributeNS(element, ns: string, attribute: string, value: string) { throw 'not implemented'; }
|
||||
removeAttribute(element, attribute: string) {
|
||||
if (attribute) {
|
||||
StringMapWrapper.delete(element.attribs, attribute);
|
||||
|
Reference in New Issue
Block a user