Conversation
src/util/tr.js
Outdated
| if (displayObj.preview && displayObj['custom-editor']) { | ||
| iframe.sandbox = 'allow-scripts allow-popups allow-popups-to-escape-sandbox' | ||
| /* eslint-disable no-cond-assign */ | ||
| var properties = {} |
There was a problem hiding this comment.
declare this variable outside the if scope to make it available on line 538
src/util/tr.js
Outdated
| var styleContent, cssBlock, cssMatch | ||
|
|
||
| // Extract style blocks | ||
| while (styleContent = styleRegex.exec(html)) { |
There was a problem hiding this comment.
did not understand this code, why are we assigning things in a while loop?
There was a problem hiding this comment.
This part is used to extract all the '<style>' block from html.
The while loop runs as long as styleRegex.exec(html) finds a match, processing each style block one at a time.
src/util/tr.js
Outdated
| while (cssBlock = ctClassRegex.exec(styleContent[1])) { | ||
| // Extract property-value pairs | ||
| while (cssMatch = cssRegex.exec(cssBlock[1])) { |
There was a problem hiding this comment.
this does not look right to me, can you explain what are you doing here?
There was a problem hiding this comment.
- 'ctClassRegex' is used to find the CSS blocks for .CT_Box or .CT_Banner within the style content.
- 'cssRegex' extracts individual CSS properties from the matched CSS block (like height: 500px;).
The two nested while loops allow the script to:
Identify and iterate over each relevant CSS block (.CT_Box or .CT_Banner).
Extract and process each CSS property within those blocks, looking specifically for the height property.
There was a problem hiding this comment.
@PraveenCTzen This can be optimized, add terminating conditions as well.
There was a problem hiding this comment.
@KambleSonam Can you help clarify the type of terminating statements we should add here?
There was a problem hiding this comment.
I meant at what condition will the loop break?
There was a problem hiding this comment.
I have updated the condition of the while loop. Please review it.
| /* eslint-disable no-cond-assign */ | ||
| var properties = {} | ||
| const styleRegex = /<style[^>]*>([^<]*)<\/style>/g | ||
| const ctClassRegex = /\.CT_(?:Box|Banner)\s*{([^}]*)}/g // Regex to match either .CT_Box or .CT_Banner |
There was a problem hiding this comment.
what about interstitial ?
There was a problem hiding this comment.
Its working fine!
There was a problem hiding this comment.
there are still console errors, can we add handling for interstitial as well?
There was a problem hiding this comment.
These errors are related to click tracking, which we are unable to perform in a sandboxed iframe.
src/util/tr.js
Outdated
| if (displayObj.preview && displayObj['custom-editor']) { | ||
| iframe.sandbox = 'allow-scripts allow-popups allow-popups-to-escape-sandbox' | ||
| /* eslint-disable no-cond-assign */ | ||
| var properties = {} |
There was a problem hiding this comment.
declare this variable outside the if scope to make it available on line 538
src/util/tr.js
Outdated
| const properties = {} | ||
| if (displayObj.preview && displayObj['custom-editor']) { | ||
| iframe.sandbox = 'allow-scripts allow-popups allow-popups-to-escape-sandbox' | ||
| /* eslint-disable no-cond-assign */ |
There was a problem hiding this comment.
we should always avoid using eslint disable unless we absolutely need to
No description provided.