Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix node validation to be applied to config node #3397

Merged

Conversation

HiroyasuNishiyama
Copy link
Member

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

After introduction of PR#3304, when deploying a new dashboard flow, the following warning is displayed.

スクリーンショット 2022-02-04 16 54 14
This is because node validation does not apply to certain config nodes (ui_base in this case).
This PR try to fix this problem.

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@coveralls
Copy link

coveralls commented Feb 4, 2022

Coverage Status

Coverage remained the same at 67.313% when pulling dc73997 on node-red-hitachi:fix-config-node-validation into 5293563 on node-red:master.

@@ -334,6 +334,9 @@ RED.deploy = (function() {
var invalidNodes = [];

RED.nodes.eachConfig(function(node) {
if (!node.hasOwnProperty("valid")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

node.hasOwnProperty should be replaced with Object.prototype.hasOwnProperty.call(node, "valid")

This is the recommended form of testing for a property that avoids errors if the object has no [[Prototype]] chain

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for your suggestion.
I fixed it not to use hasOwnProperty. However, I feel that Object.prototype.hasOwnProperty.call (node," valid ") is too long 😵‍💫 so I adopted undefined check.
It would be nice to have a utility such as RED.util.hasOwnProperty.

Copy link
Member

Choose a reason for hiding this comment

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

node.hasOwnProperty should be replaced with Object.prototype.hasOwnProperty.call(node, "valid")

It will depend on where the object has come from. If it is one we are creating, then we know it has a prototype because we don't create null objects. In this instance, we know node is vanilla JavaScript Object that has been generated by JSON.parse().

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.

None yet

4 participants