mancha 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -1,13 +1,25 @@
1
1
  "use strict";
2
- var _a, _b;
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var _a, _b, _c, _d;
3
12
  Object.defineProperty(exports, "__esModule", { value: true });
4
13
  const Mancha = require("./web.js");
5
14
  self["Mancha"] = Mancha;
6
15
  if (((_b = (_a = self.document) === null || _a === void 0 ? void 0 : _a.currentScript) === null || _b === void 0 ? void 0 : _b.getAttribute("init")) !== undefined) {
7
16
  const vars = JSON.parse(self.document.currentScript.dataset["vars"] || "{}");
8
17
  const fsroot = self.location.href.split("/").slice(0, -1).join("/") + "/";
9
- Mancha.renderContent(self.document.body.innerHTML, vars, fsroot).then((content) => {
10
- self.document.body.innerHTML = content;
11
- });
18
+ const targets = ((_d = (_c = self.document.currentScript) === null || _c === void 0 ? void 0 : _c.getAttribute("target")) === null || _d === void 0 ? void 0 : _d.split(",")) || ["body"];
19
+ targets.forEach((target) => __awaiter(void 0, void 0, void 0, function* () {
20
+ console.log(`Replacing target ${target}.`);
21
+ const node = self.document[target];
22
+ node.innerHTML = yield Mancha.renderContent(node.innerHTML, vars, fsroot);
23
+ }));
12
24
  }
13
25
  exports.default = Mancha;