New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fewer moving parts more like safe text #590
fix: fewer moving parts more like safe text #590
Conversation
* @param {strings} [] - strings to join | ||
* @returns {string} - joined strings | ||
*/ | ||
export function concatenateStringsWithSpace(strings: string[]): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're always concatenating exactly two strings so we can template them together instead
Size Change: -507 B (0%) Total Size: 2.29 MB
ℹ️ View Unchanged
|
if (target && target.nodeType === 1 && target.children?.length > 0) { | ||
for (const child of target.children) { | ||
if (child && child.nodeType === 1 && child.tagName?.toLowerCase() === 'span') { | ||
if (target && target.childNodes && target.childNodes.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't actually make a tonne of sense to use childNodes
since that will include comment and text nodes as well as elements. But none of this makes sense and we don't get (or don't notice) errors from getSafeText
so I wanted to shift this to be as similar as possible.
It iterates childNodes
with _each
so that's what I've changed this to do
We check target.childNodes
&& target.childNodes.length
so it is implicit that Element
is not a text or comment node. We then check that the child has a tagName === span
, so it is implicit there too
@@ -78,7 +78,7 @@ const autocapture = { | |||
tag_name: tag_name, | |||
} | |||
if (autocaptureCompatibleElements.indexOf(tag_name) > -1 && !maskText) { | |||
if (elem.tagName.toLowerCase() === 'a' || elem.tagName.toLowerCase() === 'button') { | |||
if (tag_name.toLowerCase() === 'a' || tag_name.toLowerCase() === 'button') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elem.tagName
is captured as tab_name
above. Using it here just for tidiness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Hopefully this does something...
Changes
I'm waiting for another build to finish and my brain was chewing at this...
I thought I'd try making it more like
getSafeText
and remove as many moving parts as I could think ofIt's very much a "poke it with a stick and see what happens change"