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

Breaking changes to Document & createNode APIs #186

Merged
merged 5 commits into from Aug 23, 2020
Merged

Commits on Aug 5, 2020

  1. Support circular references in doc.schema.createNode

    Previously, circular refs only worked in YAML.stringify. This adds a
    second arg to the Schema constructor, as createNode needs a ref for the
    anchors object.
    
    BREAKING CHANGE: If you previously used
        doc.schema.createPair(key, value, { wrapScalars: true })
    then you'll need to replace that with
        doc.schema.createPair(key, value, true)
    eemeli committed Aug 5, 2020
    Copy the full SHA
    d7b985e View commit details
    Browse the repository at this point in the history
  2. Add value as new first arg of Document constructor

    BREAKING CHANGE: `options` is now the second rather than first argument
    for `new YAML.Document(value, options)`. If you previously had:
        const doc = new YAML.Document({ version: '1.1' })
        doc.setSchema()
        doc.contents = doc.schema.createNode({ some: 'value' })
    you should replace that with:
        const doc = new YAML.Document({ some: 'value' }, { version: '1.1' })
    
    Calling the constructor with no arguments has the exact same behaviour
    as previously. Calling it with a defined value will initialise its
    `contents` with that value, as well as initialising the `schema`.
    eemeli committed Aug 5, 2020
    Copy the full SHA
    538cb7a View commit details
    Browse the repository at this point in the history
  3. Move createNode & createPair from Schema to Document

    BREAKING CHANGE: The createNode & createPair methods are moved from the
    Schema instance to the Document instance, and their options arguments
    are now collected into an object. So where you may have previously had:
        doc.schema.createNode(value, false, '!!omap')
    you should now use:
        doc.createNode(value, { tag: '!!omap', wrapScalars: false })
    and similarly for createPair(key, value).
    eemeli committed Aug 5, 2020
    Copy the full SHA
    fae1614 View commit details
    Browse the repository at this point in the history
  4. Resolve circular dependencies

    eemeli committed Aug 5, 2020
    Copy the full SHA
    5d2b627 View commit details
    Browse the repository at this point in the history
  5. Remove YAML.createNode()

    BREAKING CHANGE: Recursively creating nodes now requires a document
    instance.
    eemeli committed Aug 5, 2020
    Copy the full SHA
    b101145 View commit details
    Browse the repository at this point in the history