Sha256: a7b59e1a7428606dd7808ce35df35a39a1373c663ad3a7de5a485086b167b640
Contents?: true
Size: 1.32 KB
Versions: 16
Compression:
Stored size: 1.32 KB
Contents
export default function withAttrs(props = {}) { return function (component) { return Object.assign( component, Alpine.reactive({ getAttr(name) { return this.$root.getAttribute(name); }, setAttr(name, value) { this.$root.setAttribute(name, value); return this; }, hasAttr(name) { return this.$root.hasAttribute(name); }, removeAttr(name) { component.$root.removeAttribute(name); return this; }, assertAttr(name, testValue) { return this.$root.getAttribute(name) === String(testValue); }, refuteAttr(name, testValue) { return !this.assertAttr(name, testValue); }, getData(name) { return this.getAttr(`data-${name}`); }, setData(name, value) { return this.setAttr(`data-${name}`, value); }, hasData(name) { return this.hasAttr(`data-${name}`); }, removeData(name) { return this.removeAttr(`data-${name}`); }, assertData(name, testValue) { return this.assertAttr(`data-${name}`, testValue); }, refuteData(name, testValue) { return !this.assertData(name, testValue); }, }) ); }; }
Version data entries
16 entries across 16 versions & 1 rubygems