Skip to content

Documents Prop Sync With Conditional Directive #2

@cblanquera

Description

@cblanquera

What version of Ink are you using?

0.1.26

What OS are you experiencing this issue?

MacOS Monterey

What Browser are you experiencing this issue?

Chrome Latest

Describe the Bug

When using conditionals like <if> in a document. The server props being sent to the client get unsynced when building. This is because conditionals represent a stateful document, but build are statically used.

Expected Behavior

The logic for considering conditionals need to be rewritten for static build files.

To Reproduce

Create an Ink Document with a conditional, for example:

<script>
  import { props } from '@stackpress/ink';
  const { show = true } = props('document');
</script>
<html>
<body>
  <if true={show}>
    <span active={true}>Showing</span>
  <else />
    <div show={false}>Not Showing</div>
  </if>
</body>
</html>

When we build, it does not consider that props would be passed in, so it would build in this case where props show is passed to the client statically all the time.

Include git repo/fork so we can easily reproduce the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions