Katochimoto/xblocks

View on GitHub
src/mixin/element/checked.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * Checked element interface
 *
 * <xb-checkbox name="a" checked>checkbox</xb-checkbox>
 * <xb-radio name="b" checked>radio 1</xb-radio> <xb-radio name="b">radio 2</xb-radio>
 * <xb-button name="c" type="checkbox" checked>button checkbox</xb-button>
 * <xb-button name="d" type="radio" checked>button radio 1</xb-button> <xb-button name="d" type="radio">button radio 2</xb-button>
 *
 * @example
 * import { create } from 'xblocks-core';
 * import mixinChecked from 'mixin/element/checked';
 *
 * create('xb-checkbox', [
 *     mixinChecked,
 *     {
 *         accessors: { ... },
 *         events: { ... },
 *         methods: { ... }
 *         ...
 *     }
 * ]);
 *
 * var e = document.createElement('xb-checkbox');
 * // read
 * console.log(e.checked)
 * // false
 *
 * // write
 * e.checked = true;
 * // true
 *
 * // jquery write
 * $(e).prop('checked', false)
 * // false
 *
 * @prop {boolean} checked
 * @type {Object}
 */
export default {
    accessors: {
        checked: {
            attribute: {
                boolean: true
            }
        }
    }
};