Skip to content

Commit 8a1857a

Browse files
Call appropriate getter or setter on runtime element
1 parent d553e84 commit 8a1857a

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/features/runtime-checks.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,23 @@ class DDGRuntimeChecks extends HTMLElement {
300300
return super[method](...args)
301301
}
302302

303+
_callSetter (prop, value) {
304+
const el = this._getElement()
305+
if (el) {
306+
el[prop] = value
307+
return
308+
}
309+
super[prop] = value
310+
}
311+
312+
_callGetter (prop) {
313+
const el = this._getElement()
314+
if (el) {
315+
return el[prop]
316+
}
317+
return super[prop]
318+
}
319+
303320
/* Native DOM element methods we're capturing to supplant values into the constructed node or store data for. */
304321

305322
set src (value) {
@@ -505,19 +522,20 @@ function overloadGetOwnPropertyDescriptor () {
505522
const capturedInterfaceOut = { ...capturedInterface }
506523
if (capturedInterface.get) {
507524
capturedInterfaceOut.get = wrapFunction(function () {
525+
let method = capturedInterface.get
508526
if (isRuntimeElement(this)) {
509-
return this[propertyName]
527+
method = () => this._callGetter(propertyName)
510528
}
511-
return capturedInterface.get.call(this)
529+
return method.call(this)
512530
}, capturedInterface.get)
513531
}
514532
if (capturedInterface.set) {
515533
capturedInterfaceOut.set = wrapFunction(function (value) {
534+
let method = capturedInterface
516535
if (isRuntimeElement(this)) {
517-
this[interfaceName] = value
518-
return
536+
method = (value) => this._callSetter(propertyName, value)
519537
}
520-
return capturedInterface.set.call(this, [value])
538+
return method.call(this, [value])
521539
}, capturedInterface.set)
522540
}
523541
return capturedInterfaceOut

0 commit comments

Comments
 (0)