diff --git a/addon/components/line-clamp.hbs b/addon/components/line-clamp.hbs index a84ce55..2066033 100644 --- a/addon/components/line-clamp.hbs +++ b/addon/components/line-clamp.hbs @@ -1,59 +1,61 @@ -
- {{#each this._textLines as |line|}} - {{#if line.lastLine}} - - {{line.text}} - {{~#if line.needsEllipsis~}} - -
{{this.ellipsis}}
- {{!-- Use div to wrap the ellipsis up so that the see more button can work after google translates the page (Issue #48)--}} - {{#if this._showMoreButton}} - - {{/if}} -
- {{~/if~}} -
- {{else if line.newLine}} -
+{{#let (element (if @tagName @tagName "div")) as |Tag|}} + + {{#each this._textLines as |line|}} + {{#if line.lastLine}} + + {{line.text}} + {{~#if line.needsEllipsis~}} + +
{{this.ellipsis}}
+ {{!-- Use div to wrap the ellipsis up so that the see more button can work after google translates the page (Issue #48)--}} + {{#if this._showMoreButton}} + + {{/if}} +
+ {{~/if~}} +
+ {{else if line.newLine}} +
+ {{else}} + {{line.text}} + {{/if}} + {{else if this._strippedText}} + {{this._strippedText}} {{else}} - {{line.text}} - {{/if}} - {{else if this._strippedText}} - {{this._strippedText}} - {{else}} - {{this.text}} - {{/each}} + {{this.text}} + {{/each}} - {{#if this._showLessButton}} - {{#unless this._truncated}} - {{#if this._expanded}} - {{this.seeLessText}} - {{/if}} - {{/unless}} - {{/if}} -
+ {{#if this._showLessButton}} + {{#unless this._truncated}} + {{#if this._expanded}} + {{this.seeLessText}} + {{/if}} + {{/unless}} + {{/if}} + +{{/let}} diff --git a/package.json b/package.json index 4c7b9cc..0562689 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "ember-batcher": "^5.0.0", "ember-cli-babel": "^7.26.11", "ember-cli-htmlbars": "^6.1.1", + "ember-element-helper": "^0.6.1", "ember-singularity": "^2.0.0", "ember-test-selectors": "^6.0.0" }, diff --git a/tests/integration/components/line-clamp-test.js b/tests/integration/components/line-clamp-test.js index 94fa22d..b1aecab 100644 --- a/tests/integration/components/line-clamp-test.js +++ b/tests/integration/components/line-clamp-test.js @@ -843,4 +843,31 @@ module('Integration | Component | line clamp', function (hooks) { .dom('[data-test-line-clamp-show-more-button]') .isFocused('show more button is focused'); }); + + test('tag name is
by default', async function (assert) { + assert.expect(1); + + await render(hbs` +
+ +
`); + + assert.dom('[data-test-line-clamp]').hasTagName('div'); + }); + + test('tag name is able to be changed', async function (assert) { + assert.expect(1); + + await render(hbs` +
+ +
`); + + assert.dom('[data-test-line-clamp]').hasTagName('p'); + }); }); diff --git a/yarn.lock b/yarn.lock index 2333a22..db34d39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1085,7 +1085,7 @@ lodash "^4.17.21" resolve "^1.20.0" -"@embroider/util@^1.6.0": +"@embroider/util@^0.39.1 || ^0.40.0 || ^0.41.0 || ^1.0.0", "@embroider/util@^1.6.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@embroider/util/-/util-1.9.0.tgz#331c46bdf106c44cb1dd6baaa9030d322c13cfca" integrity sha512-9I63iJK6N01OHJafmS/BX0msUkTlmhFMIEmDl/SRNACVi0nS6QfNyTgTTeji1P/DALf6eobg/9t/N4VhS9G9QA== @@ -3593,7 +3593,7 @@ ember-cli-htmlbars@^5.3.1, ember-cli-htmlbars@^5.7.1: strip-bom "^4.0.0" walk-sync "^2.2.0" -ember-cli-htmlbars@^6.1.1: +ember-cli-htmlbars@^6.0.1, ember-cli-htmlbars@^6.1.1: version "6.1.1" resolved "https://registry.yarnpkg.com/ember-cli-htmlbars/-/ember-cli-htmlbars-6.1.1.tgz#f5b588572a5d18ad087560122b8dabc90145173d" integrity sha512-DKf2rjzIVw9zWCuFsBGJScrgf5Mz7dSg08Cq+FWFYIxnpssINUbNUoB0NHWnUJK4QqCvaExOyOmjm0kO455CPg== @@ -3854,6 +3854,15 @@ ember-disable-prototype-extensions@^1.1.3: resolved "https://registry.yarnpkg.com/ember-disable-prototype-extensions/-/ember-disable-prototype-extensions-1.1.3.tgz#1969135217654b5e278f9fe2d9d4e49b5720329e" integrity sha512-SB9NcZ27OtoUk+gfalsc3QU17+54OoqR668qHcuvHByk4KAhGxCKlkm9EBlKJcGr7yceOOAJqohTcCEBqfRw9g== +ember-element-helper@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/ember-element-helper/-/ember-element-helper-0.6.1.tgz#a6fbc5be5f875b5c864ae61bf5c5f81d6de6d936" + integrity sha512-YiOdAMlzYul4ulkIoNp8z7iHDfbT1fbut/9xGFRfxDwU/FmF8HtAUB2f1veu/w50HTeZNopa1OV2PCloZ76XlQ== + dependencies: + "@embroider/util" "^0.39.1 || ^0.40.0 || ^0.41.0 || ^1.0.0" + ember-cli-babel "^7.26.11" + ember-cli-htmlbars "^6.0.1" + ember-export-application-global@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.1.tgz#b120a70e322ab208defc9e2daebe8d0dfc2dcd46"