MCPcopy
hub / github.com/clientIO/joint / V

Function V

packages/joint-core/src/V/index.mjs:39–106  ·  view source on GitHub ↗
(el, attrs, children)

Source from the content-addressed store, hash-verified

37 var sin = math.sin;
38
39 var V = function(el, attrs, children) {
40
41 // This allows using V() without the new keyword.
42 if (!(this instanceof V)) {
43 return V.apply(Object.create(V.prototype), arguments);
44 }
45
46 if (!el) return;
47
48 if (V.isV(el)) {
49 el = el.node;
50 }
51
52 attrs = attrs || {};
53
54 if (V.isString(el)) {
55
56 el = el.trim();
57
58 if (el.toLowerCase() === 'svg') {
59
60 // Create a new SVG canvas.
61 el = V.createSvgDocument();
62
63 } else if (el[0] === '<') {
64
65 // Create element from an SVG string.
66 // Allows constructs of type: `document.appendChild(V('<rect></rect>').node)`.
67
68 var svgDoc = V.createSvgDocument(el);
69
70 // Note that `V()` might also return an array should the SVG string passed as
71 // the first argument contain more than one root element.
72 if (svgDoc.childNodes.length > 1) {
73
74 // Map child nodes to `V`s.
75 var arrayOfVels = [];
76 var i, len;
77
78 for (i = 0, len = svgDoc.childNodes.length; i < len; i++) {
79
80 var childNode = svgDoc.childNodes[i];
81 arrayOfVels.push(new V(document.importNode(childNode, true)));
82 }
83
84 return arrayOfVels;
85 }
86
87 el = document.importNode(svgDoc.firstChild, true);
88
89 } else {
90
91 el = createSVGElement(el);
92 }
93
94 V.ensureId(el);
95 }
96

Callers 15

ComponentFunction · 0.90
updateExtrasMethod · 0.90
drawGridFunction · 0.90
normalizeDataPathFunction · 0.85
normalizeSvgAttrFunction · 0.85
utils.jsFile · 0.85
links.jsFile · 0.85
basic.jsFile · 0.85
cellView.jsFile · 0.85
linkView.jsFile · 0.85
paper.jsFile · 0.85
getGridVelFunction · 0.85

Calls 5

createSVGElementFunction · 0.90
isVMethod · 0.80
isStringMethod · 0.80
ensureIdMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected