Skip to content

Conversation

@Sorryhx
Copy link
Contributor

@Sorryhx Sorryhx commented Dec 20, 2023

Description

@antv/x6-plugin-export's options table show that the default-value of serializeImages and copyStyles is the true.However, the option argument has been set {} which will cause serializeImages or copyStyles is undefined in runtime. the logical truth code won't be executed.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Enhancement (changes that improvement of current feature or performance)
  • Refactoring (changes that neither fixes a bug nor adds a feature)
  • Test Case (changes that add missing tests or correct existing tests)
  • Code style optimization (changes that do not affect the meaning of the code)
  • Docs (changes that only update documentation)
  • Chore (changes that don't modify src or test files)

Self Check before Merge

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

// without instance.hasOwnProperty method cause by ts rule.
// the condition will be false if these properties have been set undefined in the target,
// but will be true if these properties are not in the target, cause the doc.
!Object.prototype.hasOwnProperty.call(options, 'copyStyle') &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the following judgment is options.copyStyles !== false, so if it is not passed, it is also executed in accordance with true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, we just have a difference about what is the true . It will execute correctly under the strict-Boolean-type. The options.copyStyles !== false is a strict un-equality which likes ===.But, the serializeImages condition in line 209 is not strict which likes ==.So, In my option, we should keep the same style about the serializeImages and copyStyle condition what are both the Boolean value through the docs on the one hand, on the other hand, It should excute false statement when the value is either '', or ``, or null,or undefined,or NAN. All above these just beacuse JS is a fuck weak type language😓.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// without instance.hasOwnProperty method cause by ts rule.
// the condition will be false if these properties have been set undefined in the target,
// but will be true if these properties are not in the target, cause the doc.
!Object.prototype.hasOwnProperty.call(options, 'copyStyle') &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@x6-bot
Copy link
Contributor

x6-bot bot commented Jan 24, 2024

👋 @Sorryhx

Congrats on merging your first pull request! 🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants