Giter Club home page Giter Club logo

Comments (3)

olebedev avatar olebedev commented on August 15, 2024

It's 'fetch's issue. Look at its API.

from goja.

dop251 avatar dop251 commented on August 15, 2024

Judging by the error you tried something like this:

vm.Set("self", map[string]interface{}{})

You definitely don't want to do this. It creates a JS wrapper around the map and every time you put a JS value into it, the value will be Export()'ed and then every time you reference it from JS it will be wrapped again. (Aside of this, the reason for the error is those wrapped maps are not extensible by default. Can't remember if there was a good reason for me to do it this way, probably not, I'll change it).

If you want to set it to an empty object it could be done like this:

vm.Set("self", vm.NewObject())

However, in browsers 'self' appears to be the global object, so to make it more compatible you should do the same. I'll probably add something like vm.GlobalObject(), but for now you can do this:

vm.RunString("var self = this")

from goja.

sleungcy avatar sleungcy commented on August 15, 2024

That's very interesting! I will definitely try this.

from goja.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.