clarity-js 0.7.31 → 0.7.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ import encode from "@src/layout/encode";
17
17
  import * as region from "@src/layout/region";
18
18
  import traverse from "@src/layout/traverse";
19
19
  import processNode from "./node";
20
+ import config from "@src/core/config";
20
21
 
21
22
  let observers: MutationObserver[] = [];
22
23
  let mutations: MutationQueue[] = [];
@@ -129,7 +130,7 @@ async function process(): Promise<void> {
129
130
  if (state === Task.Wait) { state = await task.suspend(timer); }
130
131
  if (state === Task.Stop) { break; }
131
132
  let target = mutation.target;
132
- let type = track(mutation, timer, instance, record.time);
133
+ let type = config.throttleDom ? track(mutation, timer, instance, record.time) : mutation.type;
133
134
  if (type && target && target.ownerDocument) { dom.parse(target.ownerDocument); }
134
135
  if (type && target && target.nodeType == Node.DOCUMENT_FRAGMENT_NODE && (target as ShadowRoot).host) { dom.parse(target as ShadowRoot); }
135
136
  switch (type) {
@@ -160,7 +161,8 @@ function track(m: MutationRecord, timer: Timer, instance: number, timestamp: num
160
161
  let value = m.target ? dom.get(m.target.parentNode) : null;
161
162
  // Check if the parent is already discovered and that the parent is not the document root
162
163
  if (value && value.data.tag !== Constant.HTML) {
163
- let inactive = time() > activePeriod;
164
+ // calculate inactive period based on the timestamp of the mutation not when the mutation is processed
165
+ let inactive = timestamp > activePeriod;
164
166
  let target = dom.get(m.target);
165
167
  let element = target && target.selector ? target.selector.join() : m.target.nodeName;
166
168
  let parent = value.selector ? value.selector.join() : Constant.Empty;
@@ -9,7 +9,7 @@ import * as schema from "@src/layout/schema";
9
9
  import { checkDocumentStyles } from "@src/layout/style";
10
10
  import { electron } from "@src/data/metadata";
11
11
 
12
- const IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last"];
12
+ const IGNORE_ATTRIBUTES = ["title", "alt", "onload", "onfocus", "onerror", "data-drupal-form-submit-last", "aria-label"];
13
13
  const newlineRegex = /[\r\n]+/g;
14
14
 
15
15
  export default function (node: Node, source: Source, timestamp: number): Node {
package/types/core.d.ts CHANGED
@@ -138,6 +138,7 @@ export interface Config {
138
138
  action?: (key: string) => void;
139
139
  dob?: number;
140
140
  delayDom?: boolean;
141
+ throttleDom?: boolean;
141
142
  }
142
143
 
143
144
  export const enum Constant {
package/types/data.d.ts CHANGED
@@ -145,7 +145,9 @@ export const enum Dimension {
145
145
  ConnectionType = 27,
146
146
  Dob = 28,
147
147
  CookieVersion = 29,
148
- DeviceFamily = 30 // Allows iOS SDK to override the DeviceFamily value parsed from UserAgent.
148
+ DeviceFamily = 30, // Allows iOS SDK to override the DeviceFamily value parsed from UserAgent.
149
+ InitialScrollTop = 31,
150
+ InitialScrollBottom = 32
149
151
  }
150
152
 
151
153
  export const enum Check {
@@ -134,8 +134,8 @@ export interface ScrollData {
134
134
  target: Target;
135
135
  x: number;
136
136
  y: number;
137
- top: string;
138
- bottom: string;
137
+ top: Node | string;
138
+ bottom: Node | string;
139
139
  }
140
140
 
141
141
  export interface SelectionData {