Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

data-loader

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-loader

data-loader Custom Element to load data declaratively

  • 3.8.22
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

data-loader

A standard Custom Element fetching data declaratively.

It follows the current v1 draft.

Will load the data at the URL defined in the src property of a source element that it contains.

It can also parse JSON from the content of a script tag of type application/json.

Usage

Example

<data-loader>
  <source src="https://www.example.com/some/data" />
</data-loader>

See it running Here.

Use with custom namespace

Only needed if the data-loader name clashes with an other existing Custom Element.

import DataLoader from "data-loader";

// Register the Custom Elements
customElements.define("namespaced-data-loader", DataLoader);

And then in the HTML, use like so:

<namespaced-data-loader>
  <source src="https://www.example.com/some/data" />
</namespaced-data-loader>

Compatibility

This element assumes support for at least ES2015. To support older browsers you might need to transpile the code you use down to the version you are planning on supporting.

You might need to use a polyfill for browsers not supporting Custom Elements v1 (not v0). See webcomponents.js or SkateJS Web Components.

API

To be completed

Properties

namedefault valueinformationDOM attributewritable
datanulldata loaded by the component (same than the data dispatched in the load event)nono
loadedfalseflag informing if data is currently loadednono
selectornullselector to extract data from the payload (see lodash.get documentation)yesno

Events

event nameinformation
errorFired when none of the URL defined in the source elements is reachable nor returns a valid response
loadFired when a URL returns a valid response, contains the data loaded (same as data property)

Keywords

FAQs

Package last updated on 04 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc