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

Error in directive tooltip bind hook: "TypeError: classList.indexOf is not a function" #69

Closed
mickeyklai opened this issue Nov 19, 2017 · 3 comments
Labels

Comments

@mickeyklai
Copy link

TypeError: classList.indexOf is not a function
at eval (v-tooltip.esm.js?455e:2456)
at Array.forEach ()
at addClasses (v-tooltip.esm.js?455e:2455)
at createTooltip (v-tooltip.esm.js?455e:3382)
at bind (v-tooltip.esm.js?455e:3414)
at callHook$1 (vue.esm.js?65d7:5855)
at _update (vue.esm.js?65d7:5780)
at Array.updateDirectives (vue.esm.js?65d7:5761)
at invokeCreateHooks (vue.esm.js?65d7:5299)
at createElm (vue.esm.js?65d7:5190)

v-tooltip version: v-tooltip@2.0.0-rc.22

I had to fix it again locally:
/**

  • Add classes to an element.
  • This method checks to ensure that the classes don't already exist before adding them.
  • It uses el.className rather than classList in order to be IE friendly.
  • @param {object} el - The element to add the classes to.
  • @param {classes} string - List of space separated classes to be added to the element.
    */
    function addClasses(el, classes) {
    const newClasses = convertToArray(classes)
    let classList = null
    if (el instanceof SVGElement) {
    classList = Array.from(el.className)
    } else {
    classList = convertToArray(el.className)
    }
    newClasses.forEach((newClass) => {
    if (classList.indexOf(newClass) === -1) {
    classList.push(newClass)
    }
    })
    if (el instanceof SVGElement) {
    el.setAttribute('class', classList.join(' '))
    } else {
    el.className = classList.join(' ')
    }
    }

/**

  • Remove classes from an element.
  • It uses el.className rather than classList in order to be IE friendly.
  • @export
  • @param {any} el The element to remove the classes from.
  • @param {any} classes List of space separated classes to be removed from the element.
    */
    function removeClasses(el, classes) {
    var newClasses = convertToArray(classes);
    let classList = null
    if (el instanceof SVGElement) {
    classList = Array.from(el.className);
    } else {
    classList = convertToArray(el.className);
    }
    newClasses.forEach(function (newClass) {
    var index = classList.indexOf(newClass);
    if (index !== -1) {
    classList.splice(index, 1);
    }
    });
    if (el instanceof SVGElement) {
    el.setAttribute('class', classList.join(' '));
    } else {
    el.className = classList.join(' ');
    }
    }

Thanks

@totomobile43
Copy link

totomobile43 commented Nov 23, 2017

Whats the status on a fix? I also have this issue.

@Akryum
Copy link
Owner

Akryum commented Nov 23, 2017

Please try the latest release.

@Akryum Akryum added the bug label Nov 23, 2017
@totomobile43
Copy link

Appreciate the quick response. Seems to be fixed now on rc 24

@Akryum Akryum closed this as completed Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants