Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Signing verification utilities
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Seal
Building blocks
Signing verification utilities
Commits
8b376c95
Commit
8b376c95
authored
4 years ago
by
Igor Markin
Browse files
Options
Downloads
Patches
Plain Diff
Get rid of querySelectorAll
parent
cfcae36b
No related branches found
No related tags found
1 merge request
!36
Fix validation cases
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/MimeVerificationService/normalizationStrategies.ts
+22
-19
22 additions, 19 deletions
...rvices/MimeVerificationService/normalizationStrategies.ts
with
22 additions
and
19 deletions
src/services/MimeVerificationService/normalizationStrategies.ts
+
22
−
19
View file @
8b376c95
...
...
@@ -59,37 +59,38 @@ export const amendOutlookNodes = (document: HTMLDocument): void => {
/**
* Get rid of attachments panes
*/
const
attachmentsPanes
=
document
.
querySelectorAll
(
"
#
OwaReferenceAttachments
"
const
attachmentsPanes
Conatiner
=
document
.
getElementById
(
"
OwaReferenceAttachments
"
);
const
attachmentsPanesEnd
s
=
document
.
querySelectorAll
(
"
#
OwaReferenceAttachmentsEnd
"
const
attachmentsPanes
Container
End
=
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
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment