setProperty method
void
setProperty(
- String propertyName,
- JSValue? value, {
- JSPropertyAttributes attributes = JSPropertyAttributes.kJSPropertyAttributeNone,
Sets a property on an object.
propertyName
A JSString containing the property's name.
value
A JSValueRef to use as the property's value.
attributes
(JSPropertyAttributes) A logically ORed set of JSPropertyAttributes to give to the property.
exception
(JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Implementation
void setProperty(
String propertyName,
JSValue? value, {
JSPropertyAttributes attributes =
JSPropertyAttributes.kJSPropertyAttributeNone,
}) {
final JSException exception = JSException.create(context);
final JSString jspropName = JSString.fromString(propertyName);
JSObjectSetProperty(
context.ref,
_ref,
jspropName.ref,
value?.ref ?? nullptr,
JSPropertyAttributes.values.indexOf(attributes),
exception.ref,
);
if (exception.shouldThrow) throw exception.error;
}