MCPcopy Create free account
hub / github.com/ampproject/amphtml / defineProperty_

Method defineProperty_

testing/describes.js:428–447  ·  view source on GitHub ↗
(obj, propertyKey, descriptor)

Source from the content-addressed store, hash-verified

426 }
427
428 defineProperty_(obj, propertyKey, descriptor) {
429 this.defineProperties_.push({
430 obj,
431 propertyKey,
432 descriptor: Object.getOwnPropertyDescriptor(obj, propertyKey),
433 });
434
435 if (descriptor) {
436 if (descriptor.configurable === false) {
437 throw new Error(
438 `sandbox.defineProperty(${obj.constructor.name},${propertyKey},{configurable=false}); ` +
439 `With configurable=false, you will not be able to restore the property!`
440 );
441 }
442 descriptor.configurable = true;
443 Object.defineProperty(obj, propertyKey, descriptor);
444 } else {
445 delete obj[propertyKey];
446 }
447 }
448
449 restoreDefineProperty_() {
450 this.defineProperties_.forEach((item) => {

Callers 1

setupMethod · 0.95

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected