diff --git a/libraries/stdlib/js-ir/runtime/kotlinJsHacks.kt b/libraries/stdlib/js-ir/runtime/kotlinJsHacks.kt index 4f2f6c169ca..c4d6699ffb6 100644 --- a/libraries/stdlib/js-ir/runtime/kotlinJsHacks.kt +++ b/libraries/stdlib/js-ir/runtime/kotlinJsHacks.kt @@ -13,6 +13,18 @@ internal fun > enumValuesIntrinsic(): Array = internal fun > enumValueOfIntrinsic(@Suppress("UNUSED_PARAMETER") name: String): T = throw IllegalStateException("Should be replaced by compiler") +@PublishedApi +internal fun safePropertyGet(self: dynamic, getterName: String, propName: String): dynamic { + val getter = self[getterName] + return if (getter != null) getter.call(self) else self[propName] +} + +@PublishedApi +internal fun safePropertySet(self: dynamic, setterName: String, propName: String, value: dynamic) { + val setter = self[setterName] + if (setter != null) setter.call(self, value) else self[propName] = value +} + /** * Implements annotated function in JavaScript. * [code] string must contain JS expression that evaluates to JS function with signature that matches annotated kotlin function