Skip to content

Commit

Permalink
1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CezaryDanielNowak committed Apr 20, 2019
1 parent 51ce83e commit 98875e7
Show file tree
Hide file tree
Showing 7 changed files with 24,227 additions and 16,773 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,18 @@ Known issues:
-----------------
- react-dotdotdot does not work with text containers with nested markup.
- `padding-bottom` CSS rule breaks clamp
- `line-height` units might be important for React-dotdotdot. We recommend `px` over `em`

Changelog
-----------------
1.3.0
- `useNativeClamp` prop is set to false by default, it was causing some issues.
- Comments are not counted as a text anymore
- Remove Github's `potential security vulnerability ` with `react-dom`

1.2.4
- Added TypeScript typings (thanks @vojty and @feimosi)

1.2.3
- Add the option to choose a tag other than `div` (thanks @Kalita-Roman)
- Fix demo on Firefox
Expand Down
40,858 changes: 24,137 additions & 16,721 deletions demo/dist/index.dist.js

Large diffs are not rendered by default.

104 changes: 62 additions & 42 deletions demo/index.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "npm run watch",
"watch": "watchify ./index.js -o ./dist/index.dist.js -t [ babelify --presets [ env react ] ]",
"build": "browserify ./index.js -o ./dist/index.dist.js -t [ babelify --presets [ env react ] ]"
},
"author": "",
"license": "ISC",
"dependencies": {
"prop-types": "*",
"react": "16.2.0",
"react-dom": "16.2.0",
"react": ">=16.2.1",
"react-dom": ">=16.2.1",
"react-dotdotdot": "file:../"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-dotdotdot",
"version": "1.2.4",
"version": "1.3.0",
"description": "Multiline text ellipsis for react",
"main": "src/index.js",
"typings": "src/index.d.ts",
Expand Down
18 changes: 13 additions & 5 deletions src/clamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,24 @@
//Current element has children, need to go deeper and get last child as a text node
if (elem.lastChild.children && elem.lastChild.children.length > 0) {
return getLastChild(Array.prototype.slice.call(elem.children).pop());
}
//Handle scenario where the last child is white-space node
else if (!elem.lastChild || !elem.lastChild.nodeValue || elem.lastChild.nodeValue === '' || elem.lastChild.nodeValue == opt.truncationChar) {
} else if (
!elem.lastChild
|| !elem.lastChild.nodeValue
|| elem.lastChild.nodeValue == opt.truncationChar
|| elem.lastChild.nodeType === Node.COMMENT_NODE
) {
// Handle scenario where the last child is white-space node
var sibling = elem.lastChild;
do {
if (!sibling) {
return;
}
//TEXT_NODE
if (sibling.nodeType === 3 && ['', opt.truncationChar].indexOf(sibling.nodeValue) === -1) {
// TEXT_NODE
if (
sibling.nodeType === 3
&& ['', opt.truncationChar].indexOf(sibling.nodeValue) === -1
&& elem.lastChild.nodeType !== Node.COMMENT_NODE
) {
return sibling;
}
if (sibling.lastChild) {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Dotdotdot.prototype.dotdotdot = function(container) {
if (!container) {
return;
}

if (this.props.clamp) {
if (container.length) {
throw new Error('Please provide exacly one child to dotdotdot');
Expand Down Expand Up @@ -82,7 +82,7 @@ Dotdotdot.propTypes = {

Dotdotdot.defaultProps = {
truncationChar: '\u2026',
useNativeClamp: true,
useNativeClamp: false,
tagName: 'div'
};

Expand Down

0 comments on commit 98875e7

Please sign in to comment.