prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
51 lines (39 loc) • 3.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (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, _invariant2.default)(abstractObject instanceof _index.AbstractObjectValue);
return abstractObject;
}
return document;
};
var _index = require("../../values/index.js");
var _utils = require("../prepack/utils.js");
var _singletons = require("../../singletons.js");
var _invariant = require("../../invariant");
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const functions = ["getElementById", "getElementByTag", "getElementByClassName", "getElementByName", "getElementByTagName", "getElementByTagNameNS", "querySelector", "querySelectorAll", "createElement", "createDocumentFragment", "createTextNode"]; /**
* 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.
*/
//# sourceMappingURL=document.js.map