All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.input-controller.js Maven / Gradle / Ivy

There is a newer version: 24.4.9
Show newest version
/**
 * @license
 * Copyright (c) 2021 - 2024 Vaadin Ltd.
 * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
 */
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';

/**
 * A controller to create and initialize slotted `` element.
 */
export class InputController extends SlotController {
  constructor(host, callback) {
    super(host, 'input', 'input', {
      initializer: (node, host) => {
        if (host.value) {
          node.value = host.value;
        }
        if (host.type) {
          node.setAttribute('type', host.type);
        }

        // Ensure every instance has unique ID
        node.id = this.defaultId;

        if (typeof callback === 'function') {
          callback(node);
        }
      },
      useUniqueId: true,
    });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy