Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swaathee committed Sep 17, 2021
1 parent 00e6564 commit a33d39d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/clarity-js/src/layout/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ export default function (node: Node, source: Source): Node {
}
break;
case "NOSCRIPT":
break;
case "META":
if (Constant.Property in attributes && Constant.Content in attributes) {
var content = attributes[Constant.Content]
let content = attributes[Constant.Content]
switch(attributes[Constant.Property]) {
case Constant.ogTitle:
dimension.log(Dimension.MetaTitle, content)
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-visualize/src/heatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function scroll(activity: ScrollMapInfo[], avgFold: number): void {
var de = doc.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
de.clientHeight, de.scrollHeight, de.offsetHeight );
canvas.height = Math.min(height, Setting.CanvasMaxHeight);
canvas.height = Math.min(height, Setting.ScrollCanvasMaxHeight);
if (canvas.width > 0 && canvas.height > 0) {
if (scrollData) {
const grd = context.createLinearGradient(0, 0, 0, canvas.height);
Expand Down
15 changes: 11 additions & 4 deletions packages/clarity-visualize/src/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export function box(event: Layout.BoxEvent): void {
}
}

function addToHashMap(hash, node)
{
// In case of selector collision, prefer the first inserted node
let element = get(hash)
hashMap[hash] = element ? element : node;
}

function resize(el: HTMLElement, width: number, height: number): void {
if (el && el.nodeType === NodeType.ELEMENT_NODE && width && height) {
el.style.width = width + Layout.Constant.Pixel;
Expand Down Expand Up @@ -99,7 +106,7 @@ export function markup(event: Layout.DomEvent): void {
// In case of polyfill, map shadow dom to it's parent for rendering purposes
// All its children should be inserted as regular children to the parent node.
nodes[node.id] = parent;
hashMap[node.hash] = parent;
addToHashMap(node.hash, parent);
break;
case Layout.Constant.ShadowDomTag:
if (parent) {
Expand All @@ -118,7 +125,7 @@ export function markup(event: Layout.DomEvent): void {
shadowRoot.appendChild(shadowStyle);
}
nodes[node.id] = shadowRoot;
hashMap[node.hash] = shadowRoot;
addToHashMap(node.hash, shadowRoot);
}
break;
case Layout.Constant.TextTag:
Expand Down Expand Up @@ -149,7 +156,7 @@ export function markup(event: Layout.DomEvent): void {
// If we are still processing discover events, keep the markup hidden until we are done
if (type === Data.Event.Discover) { htmlDoc.documentElement.style.visibility = Constant.Hidden; }
nodes[node.id] = htmlDoc.documentElement;
hashMap[node.hash] = htmlDoc.documentElement;
addToHashMap(node.hash, htmlDoc.documentElement);
}
break;
case "HEAD":
Expand Down Expand Up @@ -270,7 +277,7 @@ function insertBefore(data: Layout.DomData, parent: Node, node: Node, next: Node
node.parentElement.removeChild(node);
}
nodes[data.id] = node;
hashMap[data.hash] = node;
addToHashMap(data.hash, node);
}

function setAttributes(node: HTMLElement, data: Layout.DomData): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-visualize/types/visualize.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ export const enum Setting {
MarkerColor = "white",
CanvasTextColor = "#323130",
CanvasTextFont = "500 12px Segoe UI",
CanvasMaxHeight = 40000
ScrollCanvasMaxHeight = 40000
}

0 comments on commit a33d39d

Please sign in to comment.