question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enforce document structure restrictions in node constructors

See original GitHub issue

Right now there are a few different constraints on the document structure that we enforce in the schema…

  • Children of the document must be blocks.
  • Children of other nodes can either be all blocks or all inlines and texts.
  • etc.

But when created a new node via Block.create or similar, there’s no schema validation. And there’s no indication if you initialize it with an invalid structure. This leads to hard to debug edge cases.

I don’t have a great solution in mind. It seems like we’d need to run the same sorts of checks for the schema on every node creation. If anyone has ideas I’d love to hear them!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oyeanujcommented, May 31, 2017

@ianstormtaylor +1 to that, would really also help with the developer experience (even if that check was turned off in production mode, sort of like React?)

0reactions
ianstormtaylorcommented, Oct 17, 2017

Sorry for not being clear—I think the logic is too much magic, since there are cases where you don’t want it to normalize for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Document node constructors (Db2 XQuery) - IBM
All document node constructors are computed constructors. A document node constructor creates a document node for which the content of the node is...
Read more >
Node Service-oriented Architecture | Codementor
Learn how to create a professional and scalable Node.js application with sound architectural design!
Read more >
Classes - JavaScript - MDN Web Docs
This is where you define class members, such as methods or constructor. Strict mode. The body of a class is executed in strict...
Read more >
Stream | Node.js v19.3.0 Documentation
Simplified construction; Implementing a writable stream ... Specific stream implementations may choose to enforce stricter limits but doing so is optional.
Read more >
Node (JavaFX 8) - Oracle Help Center
Defines whether or not this node's layout will be managed by it's parent. ... See the class documentation for Node for scene graph...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found