Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: make <a> tags SVG elements when they have xlink:href.
Needs a test case.
- Loading branch information
Emily Stark
committed
Jun 20, 2014
1 parent
b31629d
commit e6fb17e
Showing
1 changed file
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,7 +347,21 @@ var materialize = function (node, parent, before, parentComponent) { | |
} else if (node instanceof HTML.Tag) { | ||
var tagName = node.tagName; | ||
var elem; | ||
if (HTML.isKnownSVGElement(tagName) && document.createElementNS) { | ||
if ((HTML.isKnownSVGElement(tagName) || | ||
// We generally aren't able to detect SVG <a> elements because | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
estark37
Contributor
|
||
// if "A" were in our list of known svg element names, then all | ||
// <a> nodes would be created using | ||
// `document.createElementNS`. But in the special case of <a | ||
// xlink:href="...">, we can at least detect that attribute and | ||
// create an SVG <a> tag in that case. | ||
// | ||
// However, we still have a general problem of knowing when to | ||
// use document.createElementNS and when to use | ||
// document.createElement; for example, font tags will always | ||
// be created as SVG elements which can cause other | ||
// problems. #1977 | ||
(tagName === "A" && node.attrs["xlink:href"]) !== undefined) && | ||
This comment has been minimized.
Sorry, something went wrong. |
||
document.createElementNS) { | ||
elem = document.createElementNS('http://www.w3.org/2000/svg', tagName); | ||
} else { | ||
elem = document.createElement(node.tagName); | ||
|
Can we not inline this? Instead add a utility function
isSVGAElement
or something.