prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
55 lines (38 loc) • 1.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _index = require("../../values/index.js");
var _utils = require("../prepack/utils.js");
var _singletons = require("../../singletons.js");
var _invariant = _interopRequireDefault(require("../../invariant"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* strict-local */
const functions = ["getElementById", "getElementByTag", "getElementByClassName", "getElementByName", "getElementByTagName", "getElementByTagNameNS", "querySelector", "querySelectorAll", "createElement", "createDocumentFragment", "createTextNode"];
function _default(realm) {
// document object
let document = new _index.ObjectValue(realm, realm.intrinsics.ObjectPrototype, "document", false); // check if we can use abstracts
if (realm.useAbstractInterpretation) {
// common methods on document
for (let name of functions) {
let func = (0, _utils.createAbstract)(realm, "function", `document.${name}`);
_singletons.Properties.Set(realm, document, name, func, false);
} // document.body
let body = new _index.ObjectValue(realm, realm.intrinsics.ObjectPrototype, "document.body");
_singletons.Properties.Set(realm, document, "body", body, false); // make abstract
let abstractObject = (0, _utils.createAbstract)(realm, document, "document");
(0, _invariant.default)(abstractObject instanceof _index.AbstractObjectValue);
return abstractObject;
}
return document;
}
//# sourceMappingURL=document.js.map