Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge remote-tracking branch 'origin/map' into 2.10.0
Conflicts: src/core/transition-attr.js src/core/transition-style.js
- Loading branch information
Showing
17 changed files
with
527 additions
and
216 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function d3_collapse(s) { | ||
return s.replace(/^\s+|\s+$/g, "").replace(/\s+/g, " "); | ||
return s.trim().replace(/\s+/g, " "); | ||
} |
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
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 |
---|---|---|
@@ -1,44 +1,59 @@ | ||
d3_selectionPrototype.attr = function(name, value) { | ||
name = d3.ns.qualify(name); | ||
|
||
// If no value is specified, return the first value. | ||
if (arguments.length < 2) { | ||
var node = this.node(); | ||
return name.local | ||
? node.getAttributeNS(name.space, name.local) | ||
: node.getAttribute(name); | ||
|
||
// For attr(string), return the attribute value for the first node. | ||
if (typeof name === "string") { | ||
var node = this.node(); | ||
name = d3.ns.qualify(name); | ||
return name.local | ||
? node.getAttributeNS(name.space, name.local) | ||
: node.getAttribute(name); | ||
} | ||
|
||
// For attr(object), the object specifies the names and values of the | ||
// attributes to set or remove. The values may be functions that are | ||
// evaluated for each element. | ||
for (value in name) this.each(d3_selection_attr(value, name[value])); | ||
return this; | ||
} | ||
|
||
return this.each(d3_selection_attr(name, value)); | ||
}; | ||
|
||
function d3_selection_attr(name, value) { | ||
name = d3.ns.qualify(name); | ||
|
||
// For attr(string, null), remove the attribute with the specified name. | ||
function attrNull() { | ||
this.removeAttribute(name); | ||
} | ||
|
||
function attrNullNS() { | ||
this.removeAttributeNS(name.space, name.local); | ||
} | ||
|
||
// For attr(string, string), set the attribute with the specified name. | ||
function attrConstant() { | ||
this.setAttribute(name, value); | ||
} | ||
|
||
function attrConstantNS() { | ||
this.setAttributeNS(name.space, name.local, value); | ||
} | ||
|
||
// For attr(string, function), evaluate the function for each element, and set | ||
// or remove the attribute as appropriate. | ||
function attrFunction() { | ||
var x = value.apply(this, arguments); | ||
if (x == null) this.removeAttribute(name); | ||
else this.setAttribute(name, x); | ||
} | ||
|
||
function attrFunctionNS() { | ||
var x = value.apply(this, arguments); | ||
if (x == null) this.removeAttributeNS(name.space, name.local); | ||
else this.setAttributeNS(name.space, name.local, x); | ||
} | ||
|
||
return this.each(value == null | ||
return value == null | ||
? (name.local ? attrNullNS : attrNull) : (typeof value === "function" | ||
? (name.local ? attrFunctionNS : attrFunction) | ||
: (name.local ? attrConstantNS : attrConstant))); | ||
}; | ||
: (name.local ? attrConstantNS : attrConstant)); | ||
} |
Oops, something went wrong.