Skip to content
Permalink
Browse files

[version] patch; @digitalcraft createTextNode() 🚀 (#146)

  • Loading branch information...
yowainwright committed Apr 17, 2019
1 parent 1876911 commit da7371b0531ba14eae48ef1bb1456a3de4cfa954
Showing with 17 additions and 8 deletions.
  1. +1 −1 dist/jquery.shave.min.js
  2. +7 −2 dist/shave.es.js
  3. +7 −2 dist/shave.js
  4. +1 −1 dist/shave.min.js
  5. +1 −1 package.json
  6. +0 −1 src/shave.js

Some generated files are not rendered by default. Learn more.

@@ -1,6 +1,6 @@
/**
shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
@version v2.5.2
@version v2.5.3
@link https://github.com/dollarshaveclub/shave#readme
@author Jeff Wainwright <yowainwright@gmail.com> (jeffry.in)
@license MIT
@@ -61,7 +61,12 @@ function shave(target, maxHeight) {
el[textProp] = spaces ? words.slice(0, max).join(' ') : words.slice(0, max);
el.insertAdjacentHTML('beforeend', charHtml);
var diff = spaces ? " ".concat(words.slice(max).join(' ')) : words.slice(max);
el.insertAdjacentHTML('beforeend', "<span class=\"".concat(classname, "\" style=\"display:none;\">").concat(diff, "</span>"));
var shavedText = document.createTextNode(diff);
var elWithShavedText = document.createElement('span');
elWithShavedText.classList.add(classname);
elWithShavedText.style.display = 'none';
elWithShavedText.appendChild(shavedText);
el.insertAdjacentElement('beforeend', elWithShavedText);
styles.height = heightStyle;
styles.maxHeight = maxHeightStyle;
}
@@ -1,6 +1,6 @@
/**
shave - Shave is a javascript plugin that truncates multi-line text within a html element based on set max height
@version v2.5.2
@version v2.5.3
@link https://github.com/dollarshaveclub/shave#readme
@author Jeff Wainwright <yowainwright@gmail.com> (jeffry.in)
@license MIT
@@ -67,7 +67,12 @@
el[textProp] = spaces ? words.slice(0, max).join(' ') : words.slice(0, max);
el.insertAdjacentHTML('beforeend', charHtml);
var diff = spaces ? " ".concat(words.slice(max).join(' ')) : words.slice(max);
el.insertAdjacentHTML('beforeend', "<span class=\"".concat(classname, "\" style=\"display:none;\">").concat(diff, "</span>"));
var shavedText = document.createTextNode(diff);
var elWithShavedText = document.createElement('span');
elWithShavedText.classList.add(classname);
elWithShavedText.style.display = 'none';
elWithShavedText.appendChild(shavedText);
el.insertAdjacentElement('beforeend', elWithShavedText);
styles.height = heightStyle;
styles.maxHeight = maxHeightStyle;
}

Some generated files are not rendered by default. Learn more.

@@ -1,6 +1,6 @@
{
"name": "shave",
"version": "2.5.2",
"version": "2.5.3",
"description": "Shave is a javascript plugin that truncates multi-line text within a html element based on set max height",
"main": "dist/shave.js",
"module": "dist/shave.es.js",
@@ -57,7 +57,6 @@ export default function shave (target, maxHeight, opts = {}) {
el.insertAdjacentHTML('beforeend', charHtml)
const diff = spaces ? ` ${words.slice(max).join(' ')}` : words.slice(max)

// https://stackoverflow.com/questions/476821/is-a-dom-text-node-guaranteed-to-not-be-interpreted-as-html
const shavedText = document.createTextNode(diff)
const elWithShavedText = document.createElement('span')
elWithShavedText.classList.add(classname)

0 comments on commit da7371b

Please sign in to comment.
You can’t perform that action at this time.