Просмотр исходного кода

fixed conflict with Prototype.js in puppeteer

Former-commit-id: 409392791d698b0aa25c7fc9d425cd18b3aca6a9
Gildas 6 лет назад
Родитель
Сommit
29006883a4

+ 1 - 1
common/ui/content/content-infobar-web.js

@@ -207,7 +207,7 @@
 	function createElement(tagName, parentElement) {
 		const element = document.createElement(tagName);
 		parentElement.appendChild(element);
-		Array.from(getComputedStyle(element), property => setProperty(element, property, "initial"));
+		Array.from(getComputedStyle(element)).forEach(property => setProperty(element, property, "initial"));
 		return element;
 	}
 

+ 1 - 1
extension/ui/content/content-ui-main.js

@@ -45,7 +45,7 @@ this.singlefile.extension.ui.content.main = this.singlefile.extension.ui.content
 
 	let logsWindowElement = createLogsWindowElement();
 	const allProperties = new Set();
-	Array.from(getComputedStyle(document.body), property => allProperties.add(property));
+	Array.from(getComputedStyle(document.body)).forEach(property => allProperties.add(property));
 
 	return {
 		markSelection,

+ 1 - 1
lib/hooks/content/content-hooks-frames-web.js

@@ -140,7 +140,7 @@
 		dispatchEvent.call(window, new UIEvent("resize"));
 		dispatchEvent.call(window, new UIEvent("scroll"));
 		const docBoundingRect = scrollingElement.getBoundingClientRect();
-		Array.from(observers, ([intersectionObserver, observer]) => {
+		Array.from(observers).forEach(([intersectionObserver, observer]) => {
 			const rootBoundingRect = observer.options && observer.options.root && observer.options.root.getBoundingClientRect();
 			const targetElements = observedElements.get(intersectionObserver);
 			if (targetElements) {

+ 1 - 1
lib/single-file/modules/html-minifier.js

@@ -151,7 +151,7 @@ this.singlefile.lib.modules.htmlMinifier = this.singlefile.lib.modules.htmlMinif
 
 	function collapseBooleanAttributes(node) {
 		if (node.nodeType == Node_ELEMENT_NODE) {
-			Array.from(node.attributes, attribute => {
+			Array.from(node.attributes).forEach(attribute => {
 				if (booleanAttributes.includes(attribute.name)) {
 					node.setAttribute(attribute.name, "");
 				}

+ 3 - 3
lib/single-file/modules/html-serializer.js

@@ -113,10 +113,10 @@ this.singlefile.lib.modules.serializer = this.singlefile.lib.modules.serializer
 		let content = "";
 		if (!omittedStartTag || element.attributes.length) {
 			content = "<" + tagName;
-			Array.from(element.attributes, attribute => content += serializeAttribute(attribute, element, compressHTML));
+			Array.from(element.attributes).forEach(attribute => content += serializeAttribute(attribute, element, compressHTML));
 			content += ">";
 		}
-		Array.from(element.childNodes, childNode => content += serialize(childNode));
+		Array.from(element.childNodes).forEach(childNode => content += serialize(childNode));
 		const omittedEndTag = compressHTML && OMITTED_END_TAGS.find(omittedEndTag => tagName == omittedEndTag.tagName && omittedEndTag.accept(element.nextSibling, element));
 		if (!omittedEndTag && !SELF_CLOSED_TAG_NAMES.includes(tagName)) {
 			content += "</" + tagName + ">";
@@ -130,7 +130,7 @@ this.singlefile.lib.modules.serializer = this.singlefile.lib.modules.serializer
 		if (!name.match(/["'>/=]/)) {
 			let value = attribute.value;
 			if (compressHTML && name == "class") {
-				value = Array.from(element.classList, className => className.trim()).join(" ");
+				value = Array.from(element.classList).map(className => className.trim()).join(" ");
 			}
 			let simpleQuotesValue;
 			value = value.replace(/&/g, "&amp;").replace(/\u00a0/g, "&nbsp;");

+ 8 - 8
lib/single-file/single-file-core.js

@@ -331,7 +331,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		async run(onloadListener, options) {
-			const resourceURLs = Array.from(this.requests.keys());
+			const resourceURLs = [...this.requests.keys()];
 			let indexResource = 0;
 			return Promise.all(resourceURLs.map(async requestKey => {
 				const [resourceURL, asBinary] = JSON.parse(requestKey);
@@ -363,7 +363,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 
 		cancel() {
 			this.cancelled = true;
-			const resourceURLs = Array.from(this.requests.keys());
+			const resourceURLs = [...this.requests.keys()];
 			resourceURLs.forEach(requestKey => {
 				const resourceRequests = this.requests.get(requestKey);
 				resourceRequests.forEach(callbacks => callbacks.reject());
@@ -1066,13 +1066,13 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		async processStylesheets() {
-			await Promise.all(Array.from(this.stylesheets, ([, stylesheetInfo]) =>
+			await Promise.all(Array.from(this.stylesheets).map(([, stylesheetInfo]) =>
 				ProcessorHelper.processStylesheet(stylesheetInfo.stylesheet.children, this.baseURI, this.options, this.cssVariables, this.batchRequest)
 			));
 		}
 
 		async processStyleAttributes() {
-			return Promise.all(Array.from(this.styles, ([, declarationList]) =>
+			return Promise.all(Array.from(this.styles).map(([, declarationList]) =>
 				ProcessorHelper.processStyle(declarationList.children.toArray(), this.baseURI, this.options, this.cssVariables, this.batchRequest)
 			));
 		}
@@ -1105,7 +1105,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		async processScripts() {
-			await Promise.all(Array.from(this.doc.querySelectorAll("script[src]"), async scriptElement => {
+			await Promise.all(Array.from(this.doc.querySelectorAll("script[src]")).map(async scriptElement => {
 				let resourceURL;
 				const scriptSrc = scriptElement.getAttribute("src");
 				scriptElement.removeAttribute("src");
@@ -1623,7 +1623,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		static async processAttribute(resourceElements, attributeName, baseURI, options, cssVariables, styles, batchRequest, processDuplicates, removeElementIfMissing) {
-			await Promise.all(Array.from(resourceElements, async resourceElement => {
+			await Promise.all(Array.from(resourceElements).map(async resourceElement => {
 				let resourceURL = resourceElement.getAttribute(attributeName);
 				resourceURL = Util.normalizeURL(resourceURL);
 				if (!Util.testIgnoredPath(resourceURL)) {
@@ -1663,7 +1663,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 
 		static async processXLinks(resourceElements, baseURI, options, batchRequest) {
 			const attributeName = "xlink:href";
-			await Promise.all(Array.from(resourceElements, async resourceElement => {
+			await Promise.all(Array.from(resourceElements).map(async resourceElement => {
 				const originalResourceURL = resourceElement.getAttribute(attributeName);
 				let resourceURL = Util.normalizeURL(originalResourceURL);
 				if (Util.testValidPath(resourceURL) && !Util.testIgnoredPath(resourceURL)) {
@@ -1698,7 +1698,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		static async processSrcset(resourceElements, attributeName, baseURI, batchRequest) {
-			await Promise.all(Array.from(resourceElements, async resourceElement => {
+			await Promise.all(Array.from(resourceElements).map(async resourceElement => {
 				const srcset = util.parseSrcset(resourceElement.getAttribute(attributeName));
 				const srcsetValues = await Promise.all(srcset.map(async srcsetValue => {
 					let resourceURL = Util.normalizeURL(srcsetValue.url);

+ 4 - 4
lib/single-file/single-file-helper.js

@@ -76,7 +76,7 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 		doc.querySelectorAll("script").forEach(element => element.textContent = element.textContent.replace(/<\/script>/gi, "<\\/script>"));
 		doc.querySelectorAll("noscript").forEach(element => {
 			const disabledNoscriptElement = doc.createElement("disabled-noscript");
-			Array.from(element.childNodes, node => disabledNoscriptElement.appendChild(node));
+			Array.from(element.childNodes).forEach(node => disabledNoscriptElement.appendChild(node));
 			disabledNoscriptElement.hidden = true;
 			element.parentElement.replaceChild(disabledNoscriptElement, element);
 		});
@@ -156,7 +156,7 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 				shadowRootInfo.delegatesFocus = element.shadowRoot.delegatesFocus;
 				shadowRootInfo.mode = element.shadowRoot.mode;
 				if (element.shadowRoot.adoptedStyleSheets && element.shadowRoot.adoptedStyleSheets.length) {
-					shadowRootInfo.adoptedStyleSheets = Array.from(element.shadowRoot.adoptedStyleSheets, stylesheet => Array.from(stylesheet.cssRules, cssRule => cssRule.cssText).join("\n"));
+					shadowRootInfo.adoptedStyleSheets = Array.from(element.shadowRoot.adoptedStyleSheets).map(stylesheet => Array.from(stylesheet.cssRules).map(cssRule => cssRule.cssText).join("\n"));
 				}
 			}
 			getElementsInfo(win, doc, element, options, data, elementHidden);
@@ -290,7 +290,7 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 	function postProcessDoc(doc, markedElements) {
 		doc.querySelectorAll("disabled-noscript").forEach(element => {
 			const noscriptElement = doc.createElement("noscript");
-			Array.from(element.childNodes, node => noscriptElement.appendChild(node));
+			Array.from(element.childNodes).forEach(node => noscriptElement.appendChild(node));
 			element.parentElement.replaceChild(noscriptElement, element);
 		});
 		doc.querySelectorAll("meta[disabled-http-equiv]").forEach(element => {
@@ -329,7 +329,7 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 					tempStyleElement.remove();
 					if (!stylesheet || stylesheet.cssRules.length != styleElement.sheet.cssRules.length) {
 						styleElement.setAttribute(STYLESHEET_ATTRIBUTE_NAME, styleIndex);
-						contents[styleIndex] = Array.from(styleElement.sheet.cssRules, cssRule => cssRule.cssText).join("\n");
+						contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(cssRule => cssRule.cssText).join("\n");
 					}
 				} catch (error) {
 					// ignored