Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useNativeClamp: false is broken #76

Open
php4fan opened this issue May 2, 2022 · 3 comments
Open

useNativeClamp: false is broken #76

php4fan opened this issue May 2, 2022 · 3 comments

Comments

@php4fan
Copy link

php4fan commented May 2, 2022

When using useNativeClamp: false I get this error:

clamp.js:117 Uncaught TypeError: Cannot read properties of null (reading 'children')
@php4fan
Copy link
Author

php4fan commented May 2, 2022

In getLastChild(elem):

            if (elem.lastChild.children && elem.lastChild.children.length > 0) {
                return getLastChild(Array.prototype.slice.call(elem.children).pop());
            }

Is this supposed to be:

            if (elem.lastChild && elem.lastChild.children && elem.lastChild.children.length > 0) {
                return getLastChild(Array.prototype.slice.call(elem.children).pop());
            }

or

            if (elem.children && elem.children.length > 0) {
                return getLastChild(Array.prototype.slice.call(elem.children).pop());
            }

?

Looks more likely to be the latter.

@php4fan
Copy link
Author

php4fan commented May 2, 2022

Also here:

            //This is the absolute last child, a text node, but something's wrong with it. Remove it and keep trying
            else if (!elem.lastChild || !elem.lastChild.nodeValue || elem.lastChild.nodeValue == '' || elem.lastChild.nodeValue == opt.truncationChar) {
                elem.lastChild.parentNode.removeChild(elem.lastChild); ///////////////// 1
                return getLastChild(element);                          ///////////////// 2
            }
  1. This throws error "cannot read property parentNode of null..." if elem.lastChild is null which is a possibility and does happen
  2. I'm pretty sure you mean elem, not element

@php4fan
Copy link
Author

php4fan commented May 2, 2022

Oh shit I'm wasting my time, this project hasn't been touched in 9 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant