ElementCreationOptions.js 847 B

1234567891011121314151617181920212223242526
  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 = "is";
  7. let value = obj === undefined || obj === null ? undefined : obj[key];
  8. if (value !== undefined) {
  9. value = conversions["DOMString"](value, { context: context + " has member 'is' that", globals: globalObject });
  10. ret[key] = value;
  11. }
  12. }
  13. };
  14. exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => {
  15. if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") {
  16. throw new globalObject.TypeError(`${context} is not an object.`);
  17. }
  18. const ret = Object.create(null);
  19. exports._convertInherit(globalObject, obj, ret, { context });
  20. return ret;
  21. };