Merge pull request #871 from universe-st/PR-Branch-eff

因同步原因,去除MutatableObserver对getCards的优化逻辑
This commit is contained in:
Spmario233 2024-01-28 18:04:53 +08:00 committed by GitHub
commit 6b6ebfb2ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 10 deletions

View File

@ -2271,14 +2271,8 @@ export class Get extends Uninstantable {
static *iterableChildNodes(node){ static *iterableChildNodes(node){
for(let i=0;i<arguments.length;i++){ for(let i=0;i<arguments.length;i++){
let arg = arguments[i]; let arg = arguments[i];
if(arg._childNodesWatcher){ for(let j=0;j<arg.childElementCount;j++){
for(let child of arg._childNodesWatcher.childNodes){ yield arg.childNodes[j];
yield child;
}
}else{
for(let j=0;j<arg.childElementCount;j++){
yield arg.childNodes[j];
}
} }
} }
} }

View File

@ -3,6 +3,7 @@
*/ */
export class ChildNodesWatcher{ export class ChildNodesWatcher{
constructor(dom){ constructor(dom){
this.dom = dom;
this.childNodes = []; this.childNodes = [];
this.observer = new MutationObserver(mutationsList=>{ this.observer = new MutationObserver(mutationsList=>{
for (let mutation of mutationsList) { for (let mutation of mutationsList) {
@ -16,7 +17,7 @@ export class ChildNodesWatcher{
} }
onChildNodesChanged(addedNodes,removedNodes) { onChildNodesChanged(addedNodes,removedNodes) {
this.childNodes.addArray(Array.from(addedNodes)); this.childNodes.addArray(Array.from(addedNodes).filter(node=>node.parentNode == this.dom));
this.childNodes.removeArray(Array.from(removedNodes)); this.childNodes.removeArray(Array.from(removedNodes));
} }
}; };

View File

@ -3234,7 +3234,7 @@ export class Player extends HTMLDivElement {
value = getCardName(card); value = getCardName(card);
} }
else { else {
value = cards[i][j]; value = card[j];
} }
if ((typeof arg2[j] == 'string' && value != arg2[j]) || if ((typeof arg2[j] == 'string' && value != arg2[j]) ||
(Array.isArray(arg2[j]) && !arg2[j].includes(value))) { (Array.isArray(arg2[j]) && !arg2[j].includes(value))) {