Skip to content

Setting properties on a V8Function #172

@kynx

Description

@kynx

My first real problem! I'm trying to do something similar to the following javascript in V8Js:

var f = function() { return "foo"; }
f.bar = "baz";
console.log(f.bar);
// baz

So I've got the following:

$v8 = new V8Js();
$f = $v8->executeString('(function() { return "foo"; })');
$f->bar = "baz"; // doesn't complain, but...
$v8->f = $f;
$v8->executeString('print(PHP.f.bar)');
// undefined

Well OK, it's a kind of crazy thing to want to do. But I've got PHP helpers being called from handlebars.js. They're passed JS functions, modify and then return them to the JS, which is expecting properties to be set. Any way around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions