Skip to content
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

Merged
merged 2 commits into from Mar 20, 2023

Conversation

pauldambra
Copy link
Member

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 of

It's very much a "poke it with a stick and see what happens change"

* @param {strings} [] - strings to join
* @returns {string} - joined strings
*/
export function concatenateStringsWithSpace(strings: string[]): string {
Copy link
Member Author

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

@github-actions
Copy link

Size Change: -507 B (0%)

Total Size: 2.29 MB

Filename Size Change
dist/array.full.js 153 kB -126 B (0%)
dist/array.js 94.1 kB -127 B (0%)
dist/es.js 93.9 kB -127 B (0%)
dist/module.js 94.2 kB -127 B (0%)
ℹ️ View Unchanged
Filename Size
dist/recorder-v2.js 92.6 kB
dist/recorder.js 58.3 kB
lib/rrweb/dist/plugins/console-record.js 26.6 kB
lib/rrweb/dist/plugins/console-record.min.js 10.8 kB
lib/rrweb/dist/plugins/console-replay.js 12.7 kB
lib/rrweb/dist/plugins/console-replay.min.js 5.72 kB
lib/rrweb/dist/plugins/sequential-id-record.js 910 B
lib/rrweb/dist/plugins/sequential-id-record.min.js 417 B
lib/rrweb/dist/plugins/sequential-id-replay.js 1.24 kB
lib/rrweb/dist/plugins/sequential-id-replay.min.js 578 B
lib/rrweb/dist/record/rrweb-record-pack.js 31.4 kB
lib/rrweb/dist/record/rrweb-record-pack.min.js 10.7 kB
lib/rrweb/dist/record/rrweb-record.js 140 kB
lib/rrweb/dist/record/rrweb-record.min.js 51.7 kB
lib/rrweb/dist/replay/rrweb-replay-unpack.js 188 kB
lib/rrweb/dist/replay/rrweb-replay-unpack.min.js 71.1 kB
lib/rrweb/dist/replay/rrweb-replay.js 172 kB
lib/rrweb/dist/replay/rrweb-replay.min.js 66.4 kB
lib/rrweb/dist/rrweb-all.js 356 kB
lib/rrweb/dist/rrweb-all.min.js 133 kB
lib/rrweb/dist/rrweb.js 302 kB
lib/rrweb/dist/rrweb.min.js 116 kB
lib/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js 1.94 kB
lib/rrweb/es/rrweb/ext/mitt/dist/mitt.es.js 1.99 kB

compressed-size-action

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) {
Copy link
Member Author

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') {
Copy link
Member Author

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

@pauldambra pauldambra changed the title spike: fewer moving parts more like safe text fix: fewer moving parts more like safe text Mar 20, 2023
@pauldambra pauldambra added the bump patch Bump patch version when this PR gets merged label Mar 20, 2023
Copy link
Member

@raquelmsmith raquelmsmith left a 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...

@pauldambra pauldambra merged commit f1cab27 into master Mar 20, 2023
11 of 12 checks passed
@pauldambra pauldambra deleted the spike/fewer-moving-parts-more-like-safe-text branch March 20, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants