Comments (4)
ObjectInstance.Properties method marked as "internal"
Not sure why I changed this; I will make it public again.
There is no overload for JavaScriptException takes a innerException parameter without line number and file name.
Sure, I can add that.
ObjectInstance.GetMissingPropertyValue(object) virtual function is completely gone.
This functionality has been replaced by the ECMAScript 6 Proxy class. You can intercept property reads and writes and much more besides. :-)
JSON.stringify(input) throws error if input set to null instead of returning "null" string value
You should use Null.Value, which represents the JavaScript null value, instead of using null directly. Jurassic doesn't handle null consistently.
from jurassic.
If anyone else was wondering how to replace invocations to the now removed ObjectInstance.GetMissingPropertyValue(object)
virtual function, an override of object GetPropertyValue(object key, object thisValue)
seems to do the trick.
I was messing about trying to figure out how to use the new ES6 Proxy functionality for this, but I couldn't figure out how it relates to ObjectInstance.GetMissingPropertyValue(object)
as suggested by Paul above.
from jurassic.
ES6 proxies allow you to wrap objects and use the wrapper to intercept operations. For example:
const target = {
value: 'original value'
};
const handler = {
get: function(target, prop, receiver) {
if (prop === 'nonexistent') {
return 'it exists now!';
}
// If the property name is not 'nonexistent' then return whatever property value is on the original object.
return Reflect.get(target, prop, receiver);
}
};
const proxy = new Proxy(target, handler);
console.log(proxy.value + ', ' + proxy.nonexistent); // prints 'original value, it exists now!'
The proxy method should be more robust (less prone to change) then using GetPropertyValue(object, object)
since it is part of the ECMAScript 6 standard, but realistically this project is in maintenance mode so it probably won't matter either way.
from jurassic.
Right.
One problem I was previously solving with ObjectInstance.GetMissingPropertyValue(object)
was about transparently providing access to the properties of a C# object with hundreds of properties without proxying each property individually. Both to save typing and to remove the need for maintenance when new properties were added to the proxied object.
I suppose it would be possible to change our setup to have parts of the current .net api actually be JS proxies which rely on a new GetADynamicPropertyValue(string)
method on the .net side. I think such a hybrid approach might complicate our API maintenance a bit though.
from jurassic.
Related Issues (20)
- HTML DOM parsing HOT 1
- Return value of CompiledScript HOT 5
- PropertyAccessorValue not visible HOT 1
- How to catch CLR Exception? HOT 7
- System.ArgumentNullException: Value cannot be null. (Parameter 'value') after update from 3.1.0 to 3.2.2 HOT 3
- JSONObject.Parse() fails when number is in scientific notation HOT 4
- ScriptEngine.EnableDebugging HOT 3
- Template of literals is slow
- JSON.stringify([].length) errors HOT 2
- JSONObject.Parse consumes more and more memory. Possible memory leak? HOT 11
- Scoping and CompiledScript.Execute vs ScriptEngine.Evaluate HOT 5
- Catching script errors at compile time HOT 2
- Currently JSONObject.Stringify returns object instead of string after upgrading from 3.1.0 to 3.2.6 HOT 3
- ScriptEngine.GetGlobalValue HOT 1
- Bug in Evaluate: Loop and variable handling HOT 2
- PM - Customer side scripting for Channels HOT 1
- Date.UTC() doesn't interpret two-digit years correctly HOT 1
- Possibility to create 'sessions' HOT 4
- Linux compability ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jurassic.