0.0.3 • Published 11 months ago

be-link-valued v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

be-link-valued

How big is this package in your project? NPM version

Monitor href attribute for enumerated values.

Microdata provides boolean / enumerated type status values via urls. For example:

<link itemprop="availability" href="https://schema.org/InStock" />In stock

What be-link-valued does is watch for changing values of the href, and broadcasts updates:

<link id=availabilityLink itemprop="availability" href="https://schema.org/InStock" be-link-valued />In stock

would result in:

availabilityLink.beEnhanced.beLinkValued.value = 'InStock';
availabilityLink.beEnhanced.beLinkValued.addEventListener('value-changed', e => {
    //fires anytime href changes
})

So the value is derived from the string after the last slash of the URL. One exception:

https://schema.org/True , https://Schema.org/False automatically maps to boolean values true/false.

Viewing 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 in a modern browser.

Importing in ES Modules:

import 'be-intl/be-link-valued.js';

Using from CDN:

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