w3c / w3c/json-ld-api

`expand(..., extractAllScripts)` and typing

Open
#592 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
106
Forks
40
PR merge metrics
No merged PRs in 30d

Description

As described in Process HTML section of the specification, it is described how expand() behaves on HTML documents with extractAllScripts option.

  • If that option is false then it will return a JSON-LD document (might be an object, an array, or perhaps a null);
  • If the option is true then expand() returns necessarily an array.

This means that the output type of expand() deterministically depends on its input parameters.

What if we could split expand() into two separate functions?

  • expand() will behave as it is behaving now, but it will print a deprecation message when extractAllScripts is true;
  • expand_all() will not accept extractAllScripts option and will always output an array. It will parse all scripts in a document.

Over time, expand() might be updated: it will no longer accept extractAllScripts option at all and it will only parse one <script> in the document.

P. S. This will be handy for YAML-LD to expand_all() multiple documents in a stream.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Process HTML section of the JSON-LD 1.1 API specification and compare the current expand() behavior for extractAllScripts=false and true. Review how a separate expand_all() API and the proposed deprecation are described, then define the API and typing changes needed for the two output shapes.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.