FIX: Workaround limitation in jquery.autoellipsis (#8747)

Calling $.ellipsis() on an element containing <br> elements would throw
an exception.
This commit is contained in:
Bianca Nenciu 2020-01-21 18:44:50 +02:00 committed by GitHub
parent 0a27086764
commit 9c628f0897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View File

@ -7,6 +7,7 @@ export default Component.extend({
const $this = $(this.element);
if ($this) {
$this.find("br").replaceWith(" ");
$this.find("hr").remove();
$this.ellipsis();
}

View File

@ -0,0 +1,32 @@
import componentTest from "helpers/component-test";
moduleForComponent("text-overflow", { integration: true });
componentTest("default", {
template: `
<style>
.overflow {
max-height: 40px;
overflow: hidden;
width: 500px;
}
</style>
<div>{{text-overflow class='overflow' text=text}}</div>`,
beforeEach() {
this.set(
"text",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nFusce convallis faucibus tortor quis vestibulum.<br>\nPhasellus pharetra dolor eget imperdiet tempor.<br>\nQuisque hendrerit magna id consectetur rutrum.<br>\nNulla vel tortor leo.<br>\nFusce ullamcorper lacus quis sodales ornare.<br>"
);
},
test(assert) {
assert.equal(
find(".overflow")
.text()
.trim(),
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nFusce convallis faucibus tortor quis vestibulum. Phasellus pharetra dolor eget imperdiet..."
);
}
});