Skip to content

bahrus/be-definitive

Repository files navigation

be-definitive () [TODO]

Published on webcomponents.org NPM version Playwright Tests How big is this package in your project?

Example 1: Inferred props

<table>
    <thead><th>Name</th><th>SSN Number</th></thead>
    <tbody>
        <tr data-ld='{"@type": "Person"}' id=temp>
            <td itemprop=name>Burt</td>
            <td itemprop=ssn>123-45-6789</td>
            <script be-definitive='{"inferProps": true}'></script>
        </tr>
        <tr data-ld='{"@type": "Person", "name": "Sally", "ssn": "987-65-4321"}'>
            <template href=#temp></template>
        </tr>
        <tr data-ld='{"@type": "Person", "name": "Sally", "ssn": "987-65-4321"}'>
            <template href=#temp></template>
        </tr>
    </tbody>
</table>

Only clone the template for other tr's if innerHTML is empty.

<table>
    <thead><th>Name</th><th>SSN Number</thead>
    <tbody>
        <template be-definitive 🫚 itemscope=my-item itemref="a13245 b39596"></template>
        <tr id=a13245 be-definitive>
            <td>
                <my-item></my-item>
                <span itemprop=name>Burt</span>
            </td>
            <td itemprop=ssn>123-45-6789</td>
        </tr>
        <tr id=b39596>
            <td itemprop=address>654 Penny Lane</td>
            <td itemprop=cellphone>345-25-2686<</td>
        </tr>
        <template itemscope=my-item></template>
    </tbody>
</table>

automatically captures the template based on itemref's. Auto expands others

Viewing this element locally

  1. Install git.
  2. Fork/clone this repo.
  3. Install node.
  4. Open command window to folder where you cloned this repo.
  5. npm install

  6. npm run serve

  7. Open http://localhost:3030/demo/dev in a modern browser.

Running Tests

> npm run test

Importing in ES Modules:

import 'be-definitive/be-definitive.js';

Using from CDN:

<script type=module crossorigin=anonymous>
    import 'https://esm.run/be-definitive';
</script>

Releases

No releases published

Packages

No packages published