Skip to content
Snippets Groups Projects
Commit 8b376c95 authored by Igor Markin's avatar Igor Markin
Browse files

Get rid of querySelectorAll

parent cfcae36b
No related branches found
No related tags found
1 merge request!36Fix validation cases
......@@ -59,37 +59,38 @@ export const amendOutlookNodes = (document: HTMLDocument): void => {
/**
* Get rid of attachments panes
*/
const attachmentsPanes = document.querySelectorAll(
"#OwaReferenceAttachments"
const attachmentsPanesConatiner = document.getElementById(
"OwaReferenceAttachments"
);
const attachmentsPanesEnds = document.querySelectorAll(
"#OwaReferenceAttachmentsEnd"
const attachmentsPanesContainerEnd = document.getElementById(
"OwaReferenceAttachmentsEnd"
);
attachmentsPanesEnds.forEach((pane) => pane.parentNode.removeChild(pane));
attachmentsPanes.forEach((pane) => {
const as = pane.querySelectorAll("a");
as.forEach((a) => {
cloneAnchorFromPane(a, pane as HTMLElement);
if (attachmentsPanesConatiner) {
const as = attachmentsPanesConatiner.getElementsByTagName("a");
Array.from(as).forEach((a) => {
cloneAnchorFromPane(a, attachmentsPanesConatiner as HTMLElement);
});
});
attachmentsPanes.forEach((pane) => {
pane.parentNode.removeChild(pane);
});
attachmentsPanesConatiner.parentNode.removeChild(attachmentsPanesConatiner);
}
attachmentsPanesContainerEnd &&
attachmentsPanesContainerEnd.parentNode.removeChild(
attachmentsPanesContainerEnd
);
/**
* Unwind spans, because sometimes Outlook wraps everything into span after sending
*/
let spans = document.querySelectorAll("span");
let spans = document.getElementsByTagName("span");
/**
* Sort spans by depth to start unwinding the deepest ones, which does not contain nested spans
*/
const spansDepths: { depth?: Array<Node> } = {};
spans.forEach((span: Node) => {
Array.from(spans).forEach((span: Node) => {
let descendant = span;
let parent = descendant.parentNode;
......@@ -122,8 +123,8 @@ export const amendOutlookNodes = (document: HTMLDocument): void => {
});
// Grab updated spans and remove all of them
spans = document.querySelectorAll("span");
spans.forEach((span) => span.parentNode.removeChild(span));
spans = document.getElementsByTagName("span");
Array.from(spans).forEach((span) => span.parentNode.removeChild(span));
};
export const amendGmailNodes = (document: HTMLDocument): void => {
......@@ -131,7 +132,9 @@ export const amendGmailNodes = (document: HTMLDocument): void => {
* Look for attachments panes and remove everything but liks
*/
const attachmentsPanes = document.querySelectorAll(".gmail_chip");
const attachmentsPanes = Array.from(
document.getElementsByClassName("gmail_chip")
);
attachmentsPanes.forEach((pane) => {
const as = pane.querySelectorAll("a");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment