playbook_ui 14.5.0.pre.alpha.javascriptassets3929 → 14.5.0.pre.alpha.javascriptassets3939

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a17530f54468b0fd1ae39720a96ecce68500d8989608ecb522bf3d81ce6dab51
4
- data.tar.gz: d65c0535da58979375763c4049debf7d290eaa9731767fb1c549c1875567477d
3
+ metadata.gz: c2ca4e8e8c3df9cdee7d02f68c3a611611053345876eb602efcdb91a16b4b076
4
+ data.tar.gz: fb337ad2f116c3f991969c8e59c06ba697828ae5af32cde1c01cb49bf06b6ee6
5
5
  SHA512:
6
- metadata.gz: c6dd57dc85fe90baa66df4c7431d4c2a8f96cc3f4ee7613e68365c9583c08170d3578da9c5240ab582f54901e08f4e4f54134bd71dca950559dff3ea336c7e42
7
- data.tar.gz: 9a72bc535035ed754ff4ba389e8bdf29a209d74135e025540ac27714deb40dec77219ff77656bb37b8cda98cf24b8e69fdf25eb349d43bb244ce25bf83b920d8
6
+ metadata.gz: c833f8f4d32140a79a374f9d2b2b642fff7341defb6fc781122288238ba851c62281797eb4307ad9859c3a5004fd756c37e25dea8aa73434ac0dc6952b345fe9
7
+ data.tar.gz: 468fdf29ec022656bedceb21a0f7e165aee5de1d469ebd541e09a0587a642f91dbee263fe8c7932b5cd06fa9cac6f73efd4852edeab71757d93f1ffd561638f2
@@ -1,47 +1,34 @@
1
- // eslint-disable-next-line
2
- // @ts-nocheck
3
- import PbEnhancedElement from "./index"
4
-
5
1
  export default class ElementObserver {
6
- matchDelegate: PbEnhancedElement
7
- target: Document
8
- _mutationObserver: MutationObserver
9
-
10
- constructor(matchDelegate: PbEnhancedElement, target = document) {
2
+ constructor(matchDelegate, target = document) {
11
3
  this.matchDelegate = matchDelegate
12
4
  this.target = target
13
5
  }
14
6
 
15
- get mutationObserver(): MutationObserver {
16
- return this._mutationObserver =
17
- this._mutationObserver || new MutationObserver((mutationList) => this.processMutationList(mutationList))
18
- }
19
-
20
- start(): void {
7
+ start() {
21
8
  this.mutationObserver.observe(this.target, { attributes: true, childList: true, subtree: true })
22
9
  this.catchup()
23
10
  }
24
11
 
25
- stop(): void {
12
+ stop() {
26
13
  this.mutationObserverdisconnect()
27
14
  }
28
15
 
29
- catchup(): void {
30
- this.handleAdditions(this.matchDelegate.matches(this.target as unknown as Element))
16
+ catchup() {
17
+ this.handleAdditions(this.matchDelegate.matches(this.target))
31
18
  }
32
19
 
33
- processMutationList(mutationList: Array<MutationRecord>): void {
20
+ processMutationList(mutationList) {
34
21
  for (const mutation of mutationList) {
35
22
  if (mutation.type == 'attributes') {
36
- this.processAttributeChange(mutation.target as Element)
23
+ this.processAttributeChange(mutation.target)
37
24
  } else if (mutation.type == 'childList') {
38
- this.processRemovedNodes(Array.from(mutation.removedNodes) as Array<Element>)
39
- this.processAddedNodes(Array.from(mutation.addedNodes) as Array<Element>)
25
+ this.processRemovedNodes(Array.from(mutation.removedNodes))
26
+ this.processAddedNodes(Array.from(mutation.addedNodes))
40
27
  }
41
28
  }
42
29
  }
43
30
 
44
- processAttributeChange(node: Element): void | Array<Element> {
31
+ processAttributeChange(node) {
45
32
  if (node.nodeType !== Node.ELEMENT_NODE) return
46
33
 
47
34
  const matches = this.matchDelegate.matches(node)
@@ -51,25 +38,30 @@ export default class ElementObserver {
51
38
  this.handleAdditions(matches)
52
39
  }
53
40
 
54
- processRemovedNodes(nodes: Array<Element>): void {
41
+ processRemovedNodes(nodes) {
55
42
  for (const node of nodes) {
56
43
  if (node.nodeType !== Node.ELEMENT_NODE) continue
57
44
  this.handleRemovals(this.matchDelegate.matches(node))
58
45
  }
59
46
  }
60
47
 
61
- processAddedNodes(nodes: Array<Element>): void {
48
+ processAddedNodes(nodes) {
62
49
  for (const node of nodes) {
63
50
  if (node.nodeType !== Node.ELEMENT_NODE) continue
64
51
  this.handleAdditions(this.matchDelegate.matches(node))
65
52
  }
66
53
  }
67
54
 
68
- handleRemovals(elements: Array<Element>): void {
55
+ handleRemovals(elements) {
69
56
  for (const element of elements) this.matchDelegate.removeMatch(element)
70
57
  }
71
58
 
72
- handleAdditions(elements: Array<Element>): void {
59
+ handleAdditions(elements) {
73
60
  for (const element of elements) this.matchDelegate.addMatch(element)
74
61
  }
62
+
63
+ get mutationObserver() {
64
+ return this._mutationObserver =
65
+ this._mutationObserver || new MutationObserver((mutationList) => this.processMutationList(mutationList))
66
+ }
75
67
  }
@@ -1,31 +1,21 @@
1
- // eslint-disable-next-line
2
- // @ts-nocheck
3
- import ElementObserver from './element_observer'
1
+ import ElementObserver from './element_observer.js'
4
2
 
5
3
  export default class PbEnhancedElement {
6
- static _elements: Map<Element, PbEnhancedElement>
7
- static _observer: ElementObserver
8
- element: Element
9
-
10
- constructor(element?: Element) {
11
- this.element = element
12
- }
13
-
14
- static get elements(): Map<Element, PbEnhancedElement> {
4
+ static get elements() {
15
5
  return this._elements = (this._elements || new Map)
16
6
  }
17
7
 
18
- static get observer(): ElementObserver {
8
+ static get observer() {
19
9
  return this._observer = (this._observer || new ElementObserver(this))
20
10
  }
21
11
 
22
- static get selector(): string {
12
+ static get selector() {
23
13
  // eslint-disable-next-line no-console
24
14
  console.warn('Define a static property for selector or redefine the matches function in a subclass.', this)
25
15
  return null
26
16
  }
27
17
 
28
- static matches(node: Element): Array<Element> {
18
+ static matches(node) {
29
19
  if (!this.selector) return []
30
20
 
31
21
  const matches = []
@@ -35,7 +25,7 @@ export default class PbEnhancedElement {
35
25
  return (matches)
36
26
  }
37
27
 
38
- static addMatch(element: Element): void {
28
+ static addMatch(element) {
39
29
  if (element._pbEnhanced || this.elements.has(element)) return
40
30
 
41
31
  const enhansedElement = new this(element)
@@ -44,7 +34,7 @@ export default class PbEnhancedElement {
44
34
  element._pbEnhanced = enhansedElement
45
35
  }
46
36
 
47
- static removeMatch(element: Element): void {
37
+ static removeMatch(element) {
48
38
  if (!this.elements.has(element)) return
49
39
 
50
40
  const enhansedElement = this.elements.get(element)
@@ -52,19 +42,22 @@ export default class PbEnhancedElement {
52
42
  this.elements.delete(element)
53
43
  }
54
44
 
55
- static start(): void {
45
+ static start() {
56
46
  this.observer.start()
57
47
  }
58
48
 
59
- static stop(): void {
49
+ static stop() {
60
50
  this.mutationObserver.stop()
61
51
  }
62
52
 
63
- connect(): void {
53
+ constructor(element) {
54
+ this.element = element
55
+ }
56
+
57
+ connect() {
64
58
  // eslint-disable-next-line no-console
65
59
  console.warn('Redefine the connect function in a subclass.', this)
66
60
  }
67
61
 
68
- // eslint-disable-next-line @typescript-eslint/no-empty-function
69
- disconnect(): void {}
62
+ disconnect() { }
70
63
  }