Commit c36befc7 authored by Mike Bostock's avatar Mike Bostock
Browse files

Only use createElement for HTML.

Fix #2737. The previous fix for #2722 meant that createElement was used to
create HTML elements in HTML documents, but it also meant it was used to create
SVG elements in SVG documents, which failed: createElement only inherits the
namespace in HTML documents, not in other document types.

https://www.w3.org/TR/dom/#dom-document-createelement
parent b561c02b
!function() {
var d3 = {
version: "3.5.15"
version: "3.5.16"
};
var d3_arraySlice = [].slice, d3_array = function(list) {
return d3_arraySlice.call(list);
......@@ -620,9 +620,10 @@
return d3_selectAll(selector, this);
};
}
var d3_nsXhtml = "http://www.w3.org/1999/xhtml";
var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
xhtml: d3_nsXhtml,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
......@@ -805,7 +806,7 @@
function d3_selection_creator(name) {
function create() {
var document = this.ownerDocument, namespace = this.namespaceURI;
return namespace && namespace !== document.documentElement.namespaceURI ? document.createElementNS(namespace, name) : document.createElement(name);
return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name);
}
function createNS() {
return this.ownerDocument.createElementNS(name.space, name.local);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,7 +3,7 @@
Package.describe({
name: "d3js:d3", // http://atmospherejs.com/d3js/d3
summary: "D3 (official): A JavaScript visualization library for HTML and SVG.",
version: "3.5.15",
version: "3.5.16",
git: "https://github.com/mbostock/d3.git"
});
......
{
"name": "d3",
"version": "3.5.15",
"version": "3.5.16",
"description": "A JavaScript visualization library for HTML and SVG.",
"keywords": [
"dom",
......
var d3_nsXhtml = "http://www.w3.org/1999/xhtml";
var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
xhtml: d3_nsXhtml,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
......
......@@ -13,9 +13,9 @@ function d3_selection_creator(name) {
function create() {
var document = this.ownerDocument,
namespace = this.namespaceURI;
return namespace && namespace !== document.documentElement.namespaceURI
? document.createElementNS(namespace, name)
: document.createElement(name);
return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml
? document.createElement(name)
: document.createElementNS(namespace, name);
}
function createNS() {
......
!function(){
var d3 = {version: "3.5.15"}; // semver
var d3 = {version: "3.5.16"}; // semver
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment