Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

Merge inherited wp-context properties from a parent instance #137

@DAreRodz

Description

@DAreRodz

If a wp-context directive is nested under another wp-context instance, the properties defined in the parent context should also be available inside the nested context.

const WpContextExample = () => {
  const contextA = { a: 'foo' };
  const contextB = { b: 'bar' };

  return (
    <div wp-context={JSON.stringify(contextA)}>
      <div wp-context={JSON.stringify(contextB)}>
        {/* `context.a` and `context.b` should be accessible here */}
      </div>
    <div>
  );
}

Right now, only context.b is accessible in that scope because contextB replaces contextA entirely.

We need to implement wp-context so that all the previous properties that don't collide are preserved, even when they are nested.

In addition, we need to agree on how Array objects would be merged. We can either append the elements or replace them according to their index.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions