FocusEventInit.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. const conversions = require("webidl-conversions");
  3. const utils = require("./utils.js");
  4. const EventTarget = require("./EventTarget.js");
  5. const UIEventInit = require("./UIEventInit.js");
  6. exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => {
  7. UIEventInit._convertInherit(globalObject, obj, ret, { context });
  8. {
  9. const key = "relatedTarget";
  10. let value = obj === undefined || obj === null ? undefined : obj[key];
  11. if (value !== undefined) {
  12. if (value === null || value === undefined) {
  13. value = null;
  14. } else {
  15. value = EventTarget.convert(globalObject, value, { context: context + " has member 'relatedTarget' that" });
  16. }
  17. ret[key] = value;
  18. } else {
  19. ret[key] = null;
  20. }
  21. }
  22. };
  23. exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
  24. if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
  25. throw new globalObject.TypeError(`${context} is not an object.`);
  26. }
  27. const ret = Object.create(null);
  28. exports._convertInherit(globalObject, obj, ret, { context });
  29. return ret;
  30. };