Skip to content

Commit 75e1ee9

Browse files
authored
fix(plugin:export): it should have default value 'true' through doc (#4111)
* fix(plugin:export): it should have default value 'true' through doc * fix(plugin:export): more logical condition after last fix --------- Co-authored-by: Kevin <[email protected]>
1 parent f2e58f9 commit 75e1ee9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/x6-plugin-export/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ export class Export extends Basecoat<Export.EventArgs> implements Graph.Plugin {
4949
toSVG(callback: Export.ToSVGCallback, options: Export.ToSVGOptions = {}) {
5050
this.notify('before:export', options)
5151

52+
// to keep pace with it's doc description witch, the default value should be true.
53+
// without Object.hasOwn method cause by ts config target.
54+
// without instance.hasOwnProperty method cause by ts rule.
55+
// the condition will be false if these properties have been set undefined in the target,
56+
// but will be true if these properties are not in the target, cause the doc.
57+
!Object.prototype.hasOwnProperty.call(options, 'copyStyle') &&
58+
(options.copyStyles = true)
59+
!Object.prototype.hasOwnProperty.call(options, 'serializeImages') &&
60+
(options.serializeImages = true)
61+
5262
const rawSVG = this.view.svg
5363
const vSVG = Vector.create(rawSVG).clone()
5464
let clonedSVG = vSVG.node as SVGSVGElement
@@ -94,7 +104,7 @@ export class Export extends Basecoat<Export.EventArgs> implements Graph.Plugin {
94104
// custom stylesheets onto the `style` attribute of each of the nodes
95105
// in SVG.
96106

97-
if (options.copyStyles !== false) {
107+
if (options.copyStyles) {
98108
const document = rawSVG.ownerDocument!
99109
const raws = Array.from(rawSVG.querySelectorAll('*'))
100110
const clones = Array.from(clonedSVG.querySelectorAll('*'))

0 commit comments

Comments
 (0)