MCPcopy Create free account
hub / github.com/BloombergGraphics/whatiscode / d3_parse_attributes

Function d3_parse_attributes

scripts/libs/d3-jetpack.js:63–75  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

61 var d3_parse_attributes_regex = /([\.#])/g;
62
63 function d3_parse_attributes(name) {
64 if (typeof name === "string") {
65 var attr = {},
66 parts = name.split(d3_parse_attributes_regex), p;
67 name = parts.shift();
68 while ((p = parts.shift())) {
69 if (p == '.') attr['class'] = attr['class'] ? attr['class'] + ' ' + parts.shift() : parts.shift();
70 else if (p == '#') attr.id = parts.shift();
71 }
72 return attr.id || attr['class'] ? { tag: name, attr: attr } : name;
73 }
74 return name;
75 }
76
77 function d3_selection_creator(name) {
78 return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? function() {

Callers 1

jetpackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected