ElementDefinitionOptions.js 879 B

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