.scrollTo is not a function
See original GitHub issueIn one of my tests I execute a method that scrolls an element. The element resultsScrollElement I’m querying like this: document.querySelector(".autosuggest__results"), and then I’m executing the scrollTo method.
I get this error:
TypeError: resultsScrollElement.scrollTo is not a function
at VueComponent.ensureItemVisible (src/Autosuggest.vue:286:32)
at VueComponent.boundFn [as ensureItemVisible] (node_modules/vue/dist/vue.runtime.common.js:187:14)
at VueComponent.setChangeItem (src/Autosuggest.vue:266:16)
at VueComponent.boundFn [as setChangeItem] (node_modules/vue/dist/vue.runtime.common.js:188:14)
at VueComponent.handleKeyStroke (src/Autosuggest.vue:216:22)
at boundFn (node_modules/vue/dist/vue.runtime.common.js:188:14)
at invoker (node_modules/vue/dist/vue.runtime.common.js:1935:18)
at HTMLInputElement.fn._withTask.fn._withTask (node_modules/vue/dist/vue.runtime.common.js:1770:18)
at Wrapper.trigger (node_modules/vue-test-utils/dist/vue-test-utils.js:1278:16)
at __tests__/autosuggest.test.js:264:23
at __tests__/autosuggest.test.js:9:9
at __tests__/autosuggest.test.js:10:21
at __tests__/autosuggest.test.js:10:21
at _callee6$ (__tests__/autosuggest.test.js:263:23)
at tryCatch (node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:299:22)
at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:117:21)
at step (node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at F (node_modules/core-js/library/modules/_export.js:35:28)
at Object.<anonymous> (node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
Console.log on the element that I’m executing scrollTo on shows this:
console.log src/Autosuggest.vue:283
HTMLDivElement { _prevClass: 'autosuggest__results' }
Using version: 1.0.0-beta.9
Thanks happy new year!!! 🍾
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
scrollTo function jQuery is not working - Stack Overflow
Try this $("#clickme").click(function() { $('html, body').animate({ scrollTop: $("#wrap2").offset().top }, 2000); return false; });.
Read more >Uncaught TypeError: this.scrollTo is not a function #11 - GitHub
I just noticed that I get this error when editing a layer name. layerSpan.addEventListener('blur', function () { if (this.
Read more >Window.scrollTo is not a function | Selenium Forum
Window.scrollTo is not a function .while using javascript executor in firefox, I am getting an error Window.scrollTo is not a function.
Read more >JQuery scrollTo function - CodePen
Using jQuery scroll to function to allow page scroll from one class to another....
Read more >scrollto is not a function - Code Examples & Solutions For This ...
scrollto is not a function javascript ; 1. $("button").on('click', function() { ; 2. window.scrollTo({ ; 3. top: $('#intro').offset().top, ; 4. left: 0, ;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This isn’t a vue-test-utils issue.
scrollToisn’t implemented in JSDOM—https://github.com/tmpvar/jsdom/blob/master/lib/jsdom/browser/Window.js#L574. If you run this in a browser thescrollTomethod exists.You can add
scrollToto the Element prototype before you mount:All Elements created after you add this code will have the
scrollTomethod.In my case I had an issue due to my vue router
scrollBehaviourproperty. Above solution did not work, instead I had to add this before the mounts: