chore: do not cache highlight agressively (#34349)
This commit is contained in:
parent
00bb17751b
commit
08af3a2f06
|
|
@ -1138,25 +1138,28 @@ export class Recorder {
|
||||||
|
|
||||||
let highlight: HighlightModel | 'clear' | 'noop' = 'noop';
|
let highlight: HighlightModel | 'clear' | 'noop' = 'noop';
|
||||||
if (state.actionSelector !== this._lastHighlightedSelector) {
|
if (state.actionSelector !== this._lastHighlightedSelector) {
|
||||||
this._lastHighlightedSelector = state.actionSelector;
|
|
||||||
const model = state.actionSelector ? querySelector(this.injectedScript, state.actionSelector, this.document) : null;
|
const model = state.actionSelector ? querySelector(this.injectedScript, state.actionSelector, this.document) : null;
|
||||||
highlight = model?.elements.length ? model : 'clear';
|
highlight = model?.elements.length ? model : 'clear';
|
||||||
|
this._lastHighlightedSelector = model?.elements.length ? state.actionSelector : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ariaTemplateJSON = JSON.stringify(state.ariaTemplate);
|
const ariaTemplateJSON = JSON.stringify(state.ariaTemplate);
|
||||||
if (this._lastHighlightedAriaTemplateJSON !== ariaTemplateJSON) {
|
if (this._lastHighlightedAriaTemplateJSON !== ariaTemplateJSON) {
|
||||||
this._lastHighlightedAriaTemplateJSON = ariaTemplateJSON;
|
|
||||||
const elements = state.ariaTemplate ? this.injectedScript.getAllByAria(this.document, state.ariaTemplate) : [];
|
const elements = state.ariaTemplate ? this.injectedScript.getAllByAria(this.document, state.ariaTemplate) : [];
|
||||||
if (elements.length)
|
if (elements.length) {
|
||||||
highlight = { elements };
|
highlight = { elements };
|
||||||
else
|
this._lastHighlightedAriaTemplateJSON = ariaTemplateJSON;
|
||||||
highlight = 'clear';
|
} else {
|
||||||
|
if (!this._lastHighlightedSelector)
|
||||||
|
highlight = 'clear';
|
||||||
|
this._lastHighlightedAriaTemplateJSON = 'undefined';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highlight === 'clear')
|
if (highlight === 'clear')
|
||||||
this.clearHighlight();
|
this.clearHighlight();
|
||||||
else if (highlight !== 'noop')
|
else if (highlight !== 'noop')
|
||||||
this.updateHighlight(highlight, false);
|
this._updateHighlight(highlight, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearHighlight() {
|
clearHighlight() {
|
||||||
|
|
@ -1299,6 +1302,12 @@ export class Recorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHighlight(model: HighlightModel | null, userGesture: boolean) {
|
updateHighlight(model: HighlightModel | null, userGesture: boolean) {
|
||||||
|
this._lastHighlightedSelector = undefined;
|
||||||
|
this._lastHighlightedAriaTemplateJSON = 'undefined';
|
||||||
|
this._updateHighlight(model, userGesture);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _updateHighlight(model: HighlightModel | null, userGesture: boolean) {
|
||||||
let tooltipText = model?.tooltipText;
|
let tooltipText = model?.tooltipText;
|
||||||
if (tooltipText === undefined && !model?.tooltipList && model?.selector)
|
if (tooltipText === undefined && !model?.tooltipList && model?.selector)
|
||||||
tooltipText = this.injectedScript.utils.asLocator(this.state.language, model.selector);
|
tooltipText = this.injectedScript.utils.asLocator(this.state.language, model.selector);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue