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

Uncaught TypeError: slots[name$1].every is not a function #10839

Closed
marfrelen opened this issue Nov 18, 2019 · 9 comments
Closed

Uncaught TypeError: slots[name$1].every is not a function #10839

marfrelen opened this issue Nov 18, 2019 · 9 comments

Comments

@marfrelen
Copy link

marfrelen commented Nov 18, 2019

Version

2.6.10

Reproduction link

https://stackoverflow.com/questions/56390672/vue-js-slotsname1-every-is-not-a-function

Steps to reproduce

I created a new Laravel Project with a couple of single file vue Components.
My app.js looks like this:

if(typeof Object.prototype.clone !== 'undefined'){
    Object.prototype.clone = function() {return JSON.parse(JSON.stringify(this));}
}

import test from "./components/test";
Vue.component('vue-test', test);

new Vue({
    el: '#app',
});

I build my compiled app.js file with Laravel.mix.

What is expected?

Something like this:

let foo = {test: 'foo'};
const bar = foo.clone();
bar.test = 'bar';

console.log(foo, bar);

{test: foo}, {test: bar}

What is actually happening?

Vue throws the following error:

Uncaught TypeError: slots[name$1].every is not a function
    at resolveSlots (app.js:82705)
    at initRender (app.js:83658)
    at VueComponent.Vue._init (app.js:85164)
    at new VueComponent (app.js:85314)
    at createComponentInstanceForVnode (app.js:83463)
    at init (app.js:83294)
    at createComponent (app.js:86140)
    at createElm (app.js:86087)
    at createChildren (app.js:86215)
    at createElm (app.js:86116)

If I remove the Object.prototype function, everything works fine.
But in the case I extended the Object.prototype object, I'll get the error above.


I hope my infomation helps you to reproduce this error.
If you need some deeper information, leave me a message at markus.lenz@ort-online.net.

Thanks and kind regards,
Markus

@posva
Copy link
Member

posva commented Nov 18, 2019

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.


When reporting a bug, please provide a boiled down (a jsfiddle or code sandbox) runnable repro so we can check it 🙂

@posva posva closed this as completed Nov 18, 2019
@marfrelen
Copy link
Author

marfrelen commented Nov 18, 2019

@posva 'cause is this a bug.

The behavior occurs in connection with Vue.

I'm not able to precompile dot vue files in jsfiddle, so it's not possible to give you a sandbox.

Maybe I can prepare a testsystem for you on our public test server tomorrow.

@posva
Copy link
Member

posva commented Nov 18, 2019

I'm sorry but that's not how it works. Please take a minute to read what is said at https://new-issue.vuejs.org/?repo=vuejs/vue it's really important for us.
It also gives you links to repros templates. One of them, the codesandbox one allows you to use vue files. But if you manage to reproduce it, please, make sure to boil it down to the minimal repro before opening a bug report as the bug could come from your code.

@marfrelen
Copy link
Author

marfrelen commented Nov 18, 2019

Thanks a lot for the codesandbox. I'll try it out tomorrow and isolate this issue :)

Maybe I'll come back later if I can localize the cause of this error.

@chuigda
Copy link

chuigda commented May 13, 2021

It's 2021 now and seems that this is still a problem (vue2).

@ebadfd
Copy link

ebadfd commented Apr 5, 2022

2022 and still have the same problem.

@endrik-exe
Copy link

Same Here 2023

But i have the hack for this, so if we want to add function prototype to Object, we need to define property instead.

so from this code

Object.prototype.listify = function(mapFn) {
    if (mapFn === undefined) {
        mapFn = (k, v) => ({ k: k, v: v });
    }

    return Object.entries(this).reduce((acc, [key, value]) => {
        acc.push(mapFn(key, value));
        return acc;
    }, []);
};

to this code

function listify(obj, mapFn) {
    if (mapFn === undefined) {
        mapFn = (k, v) => ({ k: k, v: v })
    }

    return Object.entries(obj).reduce((acc, [key, value]) => {
        acc.push(mapFn(key, value))
        return acc
    }, []);
};

Object.defineProperty(Object.prototype, 'listify', {
    get: function () {
        return (mapFn) => {
            return listify(this, mapFn)
        };
    },
})

i know it's not solution, but rather a hack, but its works

@JaderCM
Copy link

JaderCM commented Apr 16, 2024

2024 and still have the same problem.

@ultravires
Copy link

May you changed Object.prototype.

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

7 participants