@cocreate/observer
Advanced tools
Comparing version 1.11.10 to 1.12.0
@@ -0,1 +1,13 @@ | ||
# [1.12.0](https://github.com/CoCreate-app/CoCreate-observer/compare/v1.11.10...v1.12.0) (2023-11-16) | ||
### Bug Fixes | ||
* callbacklist condition ([68be1f6](https://github.com/CoCreate-app/CoCreate-observer/commit/68be1f6398ce59cb70b26f1537fb75f874201ddf)) | ||
### Features | ||
* support special selectors that end in [] ([ff24e72](https://github.com/CoCreate-app/CoCreate-observer/commit/ff24e72781d0f27bcfae31c043cdc591cdf39ec1)) | ||
## [1.11.10](https://github.com/CoCreate-app/CoCreate-observer/compare/v1.11.9...v1.11.10) (2023-11-12) | ||
@@ -2,0 +14,0 @@ |
{ | ||
"name": "@cocreate/observer", | ||
"version": "1.11.10", | ||
"version": "1.12.0", | ||
"description": "Register a components init function & observe selector. The init function will be fired immedietly after detection of selector.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -381,16 +381,23 @@ // TODO: run for all mutaitonList addedNodes and removed nodes match with this.mapCallback | ||
let callbackType = callbacks[name] | ||
let { | ||
callback, | ||
selector | ||
} = callbackList[name]; | ||
if (callbackType === "callback") { | ||
benchmarker.stop('mutation') | ||
callback(mutation); | ||
benchmarker.start('mutation') | ||
if (callbackList[name]) { | ||
let { | ||
callback, | ||
selector | ||
} = callbackList[name]; | ||
if (callbackType === "callback") { | ||
benchmarker.stop('mutation') | ||
callback(mutation); | ||
benchmarker.start('mutation') | ||
} | ||
else if (callbackType === "query") { | ||
if (selector.endsWith('[]')) { | ||
if (!mutation.target.matches(selector.slice(0, -2))) | ||
continue | ||
} else if (!mutation.target.matches(selector)) | ||
continue | ||
benchmarker.stop('mutation') | ||
callback(mutation); | ||
benchmarker.start('mutation') | ||
} | ||
} | ||
else if (callbackType === "query" && mutation.target.matches(selector)) { | ||
benchmarker.stop('mutation') | ||
callback(mutation); | ||
benchmarker.start('mutation') | ||
} | ||
} | ||
@@ -444,3 +451,7 @@ }; | ||
for (let el of elements) { | ||
if (el.matches(selector)) matchedEl.push(el); | ||
if (selector.endsWith('[]')) { | ||
if (el.matches(selector.slice(0, -2))) | ||
matchedEl.push(el) | ||
} else if (el.matches(selector)) | ||
matchedEl.push(el); | ||
} | ||
@@ -447,0 +458,0 @@ if (matchedEl.length) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166312
1047