You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specifially in the src/contentScripts/utils/serialization/serializeTabState.ts file, the following update fixes the bug. However, in making this change the xpaths that are saved to local storage when the layover is closed get corrupted. So with the following fix, you can update the code so that a completely new search is performed when the layover is re-opened instead of restoring the highlight spans.
Part 1 of the fix:
// src/utils/serializeTabState.tsimport{JSONString,SerializedTabState,TabState,XPathMatchObject,}from'../../types/tab.types';functiongetXPath(element: Node): string{if(element.nodeType!==Node.ELEMENT_NODE){return'';}consthtmlElement=elementasHTMLElement;if(htmlElement.id!==''){return`//*[@id="${htmlElement.id}"]`;}if(htmlElement===document.body){returnhtmlElement.tagName;}letindex=1;letsibling=htmlElement.previousElementSibling;while(sibling){if(sibling.tagName===htmlElement.tagName){index+=1;}sibling=sibling.previousElementSibling;}return`${getXPath(htmlElement.parentNodeasNode)}/${htmlElement.tagName}[${index}]`;}functiongenerateXPaths(matchesObj: HTMLSpanElement[]): XPathMatchObject[]{constxpaths: XPathMatchObject[]=matchesObj.map((el)=>{constxpath: string=getXPath(elasNode);// generate XPath for the span element itselfconsttext=el.textContent||'';constspanClasses=Array.from(el.classList);return{ xpath, text, spanClasses };});returnxpaths;}exportdefaultfunctionserializeTabState(shallowStateObject: TabState): SerializedTabState{const{ matchesObj, ...otherProperties}=shallowStateObject;console.log('matchesObj',matchesObj);console.log('otherProperties',otherProperties);constxpaths: XPathMatchObject[]=generateXPaths(matchesObj);constserializedXPaths: JSONString=JSON.stringify(xpaths);constserializedState: SerializedTabState={
...otherProperties,serializedMatches: serializedXPaths,};returnserializedState;}```
The text was updated successfully, but these errors were encountered:
Fix started in multiple-matches-in-one-element-bug branch.
Specifially in the
src/contentScripts/utils/serialization/serializeTabState.ts
file, the following update fixes the bug. However, in making this change the xpaths that are saved to local storage when the layover is closed get corrupted. So with the following fix, you can update the code so that a completely new search is performed when the layover is re-opened instead of restoring the highlight spans.Part 1 of the fix:
The text was updated successfully, but these errors were encountered: