setProperty method

void setProperty(
  1. String propertyName,
  2. JSValue? value, {
  3. JSPropertyAttributes attributes = JSPropertyAttributes.kJSPropertyAttributeNone,
})

Implementation

void setProperty(String propertyName, JSValue? value, {JSPropertyAttributes attributes = JSPropertyAttributes.kJSPropertyAttributeNone}) {
  final JSException exception = JSException.create(_context);
  final JSString jsPropertyName = JSString.fromString(propertyName);
  try {
    js_bd.JSObjectSetProperty(_context.ref, _ref, jsPropertyName.ref, value?.ref ?? nullptr, JSPropertyAttributes.values.indexOf(attributes), exception.ref);
    if (exception.shouldThrow) {
      throw exception.error;
    }
  } finally {
    jsPropertyName.release();
    exception.release();
  }
}