Sha256: ea442bfd39fd15b0b6bee465daad8575c1756207e2c6501001f130029c353f03

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

import { get, set } from '@ember/-internals/metal';
import EmberComponent from '../component';
import layout from '../templates/empty';
/**
@module @ember/component
*/
/**
  The internal class used to create text inputs when the `{{input}}`
  helper is used with `type` of `checkbox`.

  See [Ember.Templates.helpers.input](/api/ember/release/classes/Ember.Templates.helpers/methods/input?anchor=input)  for usage details.

  ## Direct manipulation of `checked`

  The `checked` attribute of an `Checkbox` object should always be set
  through the Ember object or by interacting with its rendered element
  representation via the mouse, keyboard, or touch. Updating the value of the
  checkbox via jQuery will result in the checked value of the object and its
  element losing synchronization.

  ## Layout and LayoutName properties

  Because HTML `input` elements are self closing `layout` and `layoutName`
  properties will not be applied.

  @class Checkbox
  @extends Component
  @public
*/
const Checkbox = EmberComponent.extend({
    layout,
    classNames: ['ember-checkbox'],
    tagName: 'input',
    attributeBindings: [
        'type',
        'checked',
        'indeterminate',
        'disabled',
        'tabindex',
        'name',
        'autofocus',
        'required',
        'form',
    ],
    type: 'checkbox',
    disabled: false,
    indeterminate: false,
    didInsertElement() {
        this._super(...arguments);
        get(this, 'element').indeterminate = !!get(this, 'indeterminate');
    },
    change() {
        set(this, 'checked', this.element.checked);
    },
});
Checkbox.toString = () => '@ember/component/checkbox';
export default Checkbox;

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/glimmer/lib/components/checkbox.js