From c2982b8ae548f523ef35fd485d6f023dc26a4d00 Mon Sep 17 00:00:00 2001 From: Jeldrik Hanschke Date: Tue, 10 Sep 2019 23:03:37 +0200 Subject: [PATCH] support passing HTML attributes to --- .../element/control/power-select-multiple.hbs | 135 +++++++++--------- .../bs-form/element/control/power-select.hbs | 135 +++++++++--------- .../control/power-select-multiple-test.js | 11 ++ .../element/control/power-select-test.js | 13 +- 4 files changed, 161 insertions(+), 133 deletions(-) diff --git a/addon/templates/components/bs-form/element/control/power-select-multiple.hbs b/addon/templates/components/bs-form/element/control/power-select-multiple.hbs index 2409353..46141df 100644 --- a/addon/templates/components/bs-form/element/control/power-select-multiple.hbs +++ b/addon/templates/components/bs-form/element/control/power-select-multiple.hbs @@ -1,68 +1,71 @@ -{{#component this.powerSelectComponent - afterOptionsComponent=@afterOptionsComponent - allowClear=@allowClear - animationEnabled=@animationEnabled - ariaDescribedBy=this.ariaDescribedBy - ariaInvalid=@ariaInvalid - ariaLabel=@ariaLabel - ariaLabelledBy=@ariaLabelledBy - beforeOptionsComponent=@beforeOptionsComponent - buildSelection=@buildSelection - calculatePosition=@calculatePosition - class=@class - closeOnSelect=@closeOnSelect - defaultHighlighted=@defaultHighlighted - destination=@destination - disabled=@disabled - dropdownClass=@dropdownClass - eventType=@eventType - extra=@extra - groupComponent=@groupComponent - highlightOnHover=@highlightOnHover - horizontalPosition=@horizontalPosition - initiallyOpened=@initiallyOpened - loadingMessage=@loadingMessage - matcher=@matcher - matchTriggerWidth=@matchTriggerWidth - noMatchesMessage=@noMatchesMessage - onBlur=@onBlur - onChange=(action this.onChange) - onClose=@onClose - onFocus=@onFocus - onInput=@onInput - onKeyDown=@onKeyDown - onOpen=@onOpen - options=@options - optionsComponent=@optionsComponent - placeholder=@placeholder - placeholderComponent=@placeholderComponent - preventScroll=@preventScroll - registerAPI=@registerAPI - renderInPlace=@renderInPlace - scrollTo=@scrollTo - search=@search - searchEnabled=@searchEnabled - searchField=(if hasBlock @searchField (if @searchField @searchField @optionLabelPath)) - searchMessage=@searchMessage - searchPlaceholder=@searchPlaceholder - selected=this.value - selectedItemComponent=@selectedItemComponent - tabindex=@tabindex - triggerClass=@triggerClass - triggerComponent=@triggerComponent - triggerId=@triggerId - triggerRole=@triggerRole - typeAheadMatcher=@typeAheadMatcher - verticalPosition=@verticalPosition - as |item select| -}} - {{#if hasBlock}} - {{yield item select}} - {{else}} - {{#if @optionLabelPath}} - {{get item @optionLabelPath}} +{{#let (component this.powerSelectComponent) as |PowerSelect|}} + + {{#if hasBlock}} + {{yield item select}} {{else}} - {{item}} + {{#if @optionLabelPath}} + {{get item @optionLabelPath}} + {{else}} + {{item}} + {{/if}} {{/if}} - {{/if}} -{{/component}} \ No newline at end of file + +{{/let}} \ No newline at end of file diff --git a/addon/templates/components/bs-form/element/control/power-select.hbs b/addon/templates/components/bs-form/element/control/power-select.hbs index 2409353..46141df 100644 --- a/addon/templates/components/bs-form/element/control/power-select.hbs +++ b/addon/templates/components/bs-form/element/control/power-select.hbs @@ -1,68 +1,71 @@ -{{#component this.powerSelectComponent - afterOptionsComponent=@afterOptionsComponent - allowClear=@allowClear - animationEnabled=@animationEnabled - ariaDescribedBy=this.ariaDescribedBy - ariaInvalid=@ariaInvalid - ariaLabel=@ariaLabel - ariaLabelledBy=@ariaLabelledBy - beforeOptionsComponent=@beforeOptionsComponent - buildSelection=@buildSelection - calculatePosition=@calculatePosition - class=@class - closeOnSelect=@closeOnSelect - defaultHighlighted=@defaultHighlighted - destination=@destination - disabled=@disabled - dropdownClass=@dropdownClass - eventType=@eventType - extra=@extra - groupComponent=@groupComponent - highlightOnHover=@highlightOnHover - horizontalPosition=@horizontalPosition - initiallyOpened=@initiallyOpened - loadingMessage=@loadingMessage - matcher=@matcher - matchTriggerWidth=@matchTriggerWidth - noMatchesMessage=@noMatchesMessage - onBlur=@onBlur - onChange=(action this.onChange) - onClose=@onClose - onFocus=@onFocus - onInput=@onInput - onKeyDown=@onKeyDown - onOpen=@onOpen - options=@options - optionsComponent=@optionsComponent - placeholder=@placeholder - placeholderComponent=@placeholderComponent - preventScroll=@preventScroll - registerAPI=@registerAPI - renderInPlace=@renderInPlace - scrollTo=@scrollTo - search=@search - searchEnabled=@searchEnabled - searchField=(if hasBlock @searchField (if @searchField @searchField @optionLabelPath)) - searchMessage=@searchMessage - searchPlaceholder=@searchPlaceholder - selected=this.value - selectedItemComponent=@selectedItemComponent - tabindex=@tabindex - triggerClass=@triggerClass - triggerComponent=@triggerComponent - triggerId=@triggerId - triggerRole=@triggerRole - typeAheadMatcher=@typeAheadMatcher - verticalPosition=@verticalPosition - as |item select| -}} - {{#if hasBlock}} - {{yield item select}} - {{else}} - {{#if @optionLabelPath}} - {{get item @optionLabelPath}} +{{#let (component this.powerSelectComponent) as |PowerSelect|}} + + {{#if hasBlock}} + {{yield item select}} {{else}} - {{item}} + {{#if @optionLabelPath}} + {{get item @optionLabelPath}} + {{else}} + {{item}} + {{/if}} {{/if}} - {{/if}} -{{/component}} \ No newline at end of file + +{{/let}} \ No newline at end of file diff --git a/tests/integration/components/bs-form/element/control/power-select-multiple-test.js b/tests/integration/components/bs-form/element/control/power-select-multiple-test.js index 8b13b2b..f534e78 100644 --- a/tests/integration/components/bs-form/element/control/power-select-multiple-test.js +++ b/tests/integration/components/bs-form/element/control/power-select-multiple-test.js @@ -147,4 +147,15 @@ module('Integration | Component | bs form/element/control/power select multiple' await clickTrigger(); assert.dom('.ember-power-select-search-input').doesNotExist(); }); + + test('it passes HTML attributes', async function(assert) { + // HTML attributes are not applied to any element if `renderInPlace` is `false` + await render(hbs` + + + + + `); + assert.dom('[data-test-foo]').exists(); + }); }); diff --git a/tests/integration/components/bs-form/element/control/power-select-test.js b/tests/integration/components/bs-form/element/control/power-select-test.js index 7a9f2f2..98dbf52 100644 --- a/tests/integration/components/bs-form/element/control/power-select-test.js +++ b/tests/integration/components/bs-form/element/control/power-select-test.js @@ -120,11 +120,22 @@ module('Integration | Component | bs form/element/control/power select', functio await render(hbs` - {{el.control searchEnabled=false triggerClass='form-control' }} + `); assert.dom('.form-control').exists(); await clickTrigger(); assert.dom('.ember-power-select-search-input').doesNotExist(); }); + + test('it passes HTML attributes', async function(assert) { + // HTML attributes are not applied to any element if `renderInPlace` is `false` + await render(hbs` + + + + + `); + assert.dom('[data-test-foo]').exists(); + }); });