Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

web.self.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var globalThis = require('../internals/global-this');
  4. var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
  5. var DESCRIPTORS = require('../internals/descriptors');
  6. var $TypeError = TypeError;
  7. // eslint-disable-next-line es/no-object-defineproperty -- safe
  8. var defineProperty = Object.defineProperty;
  9. var INCORRECT_VALUE = globalThis.self !== globalThis;
  10. // `self` getter
  11. // https://html.spec.whatwg.org/multipage/window-object.html#dom-self
  12. try {
  13. if (DESCRIPTORS) {
  14. // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
  15. var descriptor = Object.getOwnPropertyDescriptor(globalThis, 'self');
  16. // some engines have `self`, but with incorrect descriptor
  17. // https://github.com/denoland/deno/issues/15765
  18. if (INCORRECT_VALUE || !descriptor || !descriptor.get || !descriptor.enumerable) {
  19. defineBuiltInAccessor(globalThis, 'self', {
  20. get: function self() {
  21. return globalThis;
  22. },
  23. set: function self(value) {
  24. if (this !== globalThis) throw new $TypeError('Illegal invocation');
  25. defineProperty(globalThis, 'self', {
  26. value: value,
  27. writable: true,
  28. configurable: true,
  29. enumerable: true
  30. });
  31. },
  32. configurable: true,
  33. enumerable: true
  34. });
  35. }
  36. } else $({ global: true, simple: true, forced: INCORRECT_VALUE }, {
  37. self: globalThis
  38. });
  39. } catch (error) { /* empty */ }