cytoscape-dom-node 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,6 +59,24 @@ The `div` you created will be shown as the node now.
59
59
  See [codepen abWdVOG](https://codepen.io/mwri/pen/abWdVOG) for a working
60
60
  example.
61
61
 
62
+ ### Skip Node Append
63
+ The `skip_node_append` option is a boolean flag (passed with node data) that controls whether the `cytoscape-dom-node` appends the provided node to the provided DOM container.
64
+ By default, this option is set to false, meaning the `cytoscape-dom-node` will append the node to the container.
65
+
66
+ However, in certain scenarios, such as when using EmberJS or another front-end framework, you might have already rendered the nodes to the DOM.
67
+ In these cases, you can set `skip_node_append` to true to prevent the library from appending the node, allowing you to maintain control over the node's rendering process.
68
+
69
+ ```js
70
+ let div = document.querySelector("#alreadyRenderedNodeId");
71
+ cy.add({
72
+ 'data': {
73
+ 'id': id,
74
+ 'dom': div,
75
+ 'skip_node_append': true,
76
+ }
77
+ })
78
+ ```
79
+
62
80
  ## Options
63
81
 
64
82
  One option is supported, `dom_container` allows an container element to be specified which
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cytoscape-dom-node",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Cytoscape extension for making nodes into DOM elements",
5
5
  "keywords": [
6
6
  "cytoscape",
package/src/index.js CHANGED
@@ -70,7 +70,9 @@ class CytoscapeDomNode {
70
70
  if (!data.dom)
71
71
  return;
72
72
 
73
- this._nodes_dom_container.appendChild(data.dom);
73
+ if (data.skip_node_append !== true) {
74
+ this._nodes_dom_container.appendChild(data.dom);
75
+ }
74
76
  data.dom.__cy_id = n.id();
75
77
 
76
78
  this._node_dom[n.id()] = data.dom;