Sha256: 1061a7326b2410d4389c83a0925eee299de3215aeb6309fd54ca70ef65d371c5

Contents?: true

Size: 678 Bytes

Versions: 12

Compression:

Stored size: 678 Bytes

Contents

import { updateComponent } from "dom/update-component";

export const initializeInputs = () => {
  const inputElements = document.querySelectorAll("[data-attribute]");
  inputElements.forEach((element: any) => {
    const attribute = element.getAttribute("data-attribute");
    const component = element.closest(`[data-component]`) as HTMLElement;
    const state = JSON.parse(component.getAttribute("data-state") || "{}");
    if (!attribute || !component) return;
    if (element.tagName === "INPUT") {
      element.addEventListener("input", (event: Event) => {
        updateComponent(component, state, attribute, event.target as HTMLInputElement);
      });
    }
  });
};

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
clapton-0.0.12 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.11 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.10 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.9 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.8 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.7 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.6 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.5 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.4 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.3 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.2 lib/clapton/javascripts/src/inputs/initialize-inputs.ts
clapton-0.0.1 lib/clapton/javascripts/src/inputs/initialize-inputs.ts