Sha256: c32068c1122e2fb9cc23ec7170d8b3b482e33ca536554a231e0966e0194b1232

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

import { get, set } from 'ember-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

2 entries across 2 versions & 1 rubygems

Version Path
discourse-ember-source-3.5.1.1 dist/es/ember-glimmer/lib/components/checkbox.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-glimmer/lib/components/checkbox.js