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

Add strict mode #48

Merged
merged 3 commits into from
Dec 20, 2022
Merged

Add strict mode #48

merged 3 commits into from
Dec 20, 2022

Conversation

nikku
Copy link
Member

@nikku nikku commented Dec 17, 2022

To aid the transition to #45, add a dedicated mode that fails early if illegal access is attempted on a ModdleElement.


Behavioral changes in a nutshell:

  • Indicated dedicated logging when setting / retrieving unknown properties
  • Add a strict mode that fails on unknown property access
  • Allow global, no namespace attributes (xmlns) to be added without warning, if explicitly flagged

The mode is optional and must be configured explitly as strict=true:

const moddle = new Moddle(..., { strict: true })

If configured with strict=false then a warning is logged to the console, indicating miss-use:

unknown property <foo> on <props:ComplexCount>

@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Dec 17, 2022
lib/moddle.js Show resolved Hide resolved
@nikku nikku added the in progress Currently worked on label Dec 19, 2022 — with bpmn-io-tasks
@nikku nikku removed the needs review Review pending label Dec 19, 2022
In strict mode `moddle` will fail on unknown property
access / instantiation.
Instead of throwing, log a warning when `strict=false` is configured.

This ensures that logging is still opt-in. It won't happen without prior
configuration:

```javascript
const moddle = new Moddle(packages, { strict: false });
```
@nikku
Copy link
Member Author

nikku commented Dec 20, 2022

@barmac Reworked this based on our discussion.

For the time being :global access is added as a non breaking feature.

At the same time the strict mode (including warnings logged) is added as a non-breaking feature.

@nikku nikku requested a review from barmac December 20, 2022 13:55
@nikku nikku added needs review Review pending and removed in progress Currently worked on labels Dec 20, 2022
@fake-join fake-join bot merged commit e7ccc60 into master Dec 20, 2022
@fake-join fake-join bot deleted the strict-mode branch December 20, 2022 16:03
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Dec 20, 2022
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