@rnacanvas/draw.svg 3.2.0 → 3.3.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
@@ -106,3 +106,32 @@ innerXML.toString(); // "<circle></circle><text>A</text>"
106
106
  // sets the `innerHTML` property of the target SVG element
107
107
  innerXML.set('<rect></rect><text>B</text>');
108
108
  ```
109
+
110
+ ## `OuterXML`
111
+
112
+ The `OuterXML` class represents the outer XML of a target SVG element.
113
+
114
+ The critical difference between the behavior of this class
115
+ and the `outerHTML` property of SVG elements
116
+ is that the `set()` method of this class modifies the target SVG element <b>in place</b>,
117
+ as opposed to replacing the target SVG element with newly created SVG element(s) in the DOM tree,
118
+ which is what setting the `outerHTML` property does.
119
+
120
+ Thus, the `set()` method will throw if the specified outer XML does not encode exactly one SVG element
121
+ or if the specified outer XML encodes an SVG element with a tag name different from that of the target SVG element.
122
+
123
+ ```javascript
124
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
125
+
126
+ svg.setAttribute('viewBox', '0 0 10 20');
127
+
128
+ svg.append(document.createElementNS('http://www.w3.org/2000/svg', 'circle'));
129
+ svg.append(document.createElementNS('http://www.w3.org/2000/svg', 'rect'));
130
+ svg.append('Some text.');
131
+
132
+ var outerXML = new OuterXML(svg);
133
+
134
+ outerXML.toString(); // '<svg viewBox="0 0 10 20"><circle></circle><rect></rect>Some text.</svg>'
135
+
136
+ outerXML.set('<svg viewBox="0 0 25 25" width="50" height="50>Different text.<path></path></svg>');
137
+ ```
@@ -1,15 +1,15 @@
1
1
  /**
2
- * Represents the inner XML of a target SVG document.
2
+ * Represents the inner XML of a target SVG element.
3
3
  */
4
4
  export declare class InnerXML {
5
5
  #private;
6
- constructor(targetSVGDoc: SVGSVGElement);
6
+ constructor(targetSVGElement: SVGElement);
7
7
  /**
8
- * Returns the `innerHTML` property of the target SVG document.
8
+ * Returns the `innerHTML` property of the target SVG element.
9
9
  */
10
10
  toString(): string;
11
11
  /**
12
- * Sets the `innerHTML` property of the target SVG document.
12
+ * Sets the `innerHTML` property of the target SVG element.
13
13
  */
14
14
  set(innerXML: string): void;
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InnerXML.d.ts","sourceRoot":"","sources":["../src/InnerXML.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAQ;;gBAGP,YAAY,EAAE,aAAa;IAIvC;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAG5B"}
1
+ {"version":3,"file":"InnerXML.d.ts","sourceRoot":"","sources":["../src/InnerXML.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAQ;;gBAGP,gBAAgB,EAAE,UAAU;IAIxC;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAG5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/draw.svg",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "SVG drawing utilities",
5
5
  "repository": {
6
6
  "type": "git",