Resolve Prototype.js Interference With Typesense/InstantSearch Implementation
TLDR John reported an error after including Prototype.js library in their website, affecting the Typesense/InstantSearch implementation. Nick suggested avoiding the old library, but John couldn't due to it being required by Magento 1.9. Jason clarified the issue and suggested an upgrade. Upgrading to Prototype.js version 7.1 mitigated the issue according to John.
2
1
May 26, 2021 (32 months ago)
John
04:49 PMAnd as soon as I include this library it kills the Typesense/InstantSearch implementation, giving the error I pasted below.
Does anyone know how I could resolve this?
uniq.ts:2 Uncaught TypeError: Cannot read property 'indexOf' of undefined
at uniq.ts:2
at prototype.js:884
at prototype.js:825
at Array.forEach (<anonymous>)
at Array.each (prototype.js:824)
at Array.findAll (prototype.js:883)
at le (uniq.ts:2)
at prepareTemplateProps.ts:26
at he (prepareTemplateProps.ts:60)
at hits.tsx:42
Nick
05:11 PM1
1
John
10:27 PMJason
11:02 PMInstantsearch.js uses the
Array.filter
function and the modern JS implementation of it takes 3 parameters.However, Prototype.js redefines
Array.filter
globally as it's own 2-argument function and that causes InstantSearch.js to error out.
Not sure if this is helpful, but may be something like this might help prevent prototype polluting the global Array object: http://perrymitchell.net/article/stop-polluting-my-prototypes/
1
John
11:15 PMJason
11:19 PMTypesense
Indexed 3015 threads (79% resolved)
Similar Threads
Resolving Typesense Setup Issues with VueJS
A sought help with setting up Typesense in a CDN VueJS application. Jason guided him to adjust the initialization and provided a solution to an undefined item warning, resulting in a successful setup.
Contributing to project using JS, TS, Go and PHP
Matthew volunteered to contribute to the project using JavaScript, Typescript, Go, and PHP. Jason assigned two tasks, including Laravel integration and nest.js library. hi019 encouraged Matthew to try out the Laravel integration.
Troubleshooting TypeScript Error with Typesense
GM experienced an error with Typesense in TypeScript, requiring help to correct the issues. Jason helped propose solutions and adjustments to the code. Ultimately, they were able to resolve the errors and successfully implement a search function.