Skip to content

Commit

Permalink
删除冗余代码;修复Labels不返回Element的潜在bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaojiaodubai committed Dec 25, 2023
1 parent 910f702 commit 8d3ff8b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Duxiu.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,15 @@ class Labels {
getWith(label, element = false) {
if (Array.isArray(label)) {
let result = label
.map(element => this.getWith(element))
.filter(element => element);
return result.length
? result.find(element => element)
: '';
.map(aLabel => this.getWith(aLabel, element));
result = element
? result.find(element => element.childNodes.length)
: result.find(element => element);
return result
? result
: element
? document.createElement('div')
: '';
}
let pattern = new RegExp(label);
let keyValPair = this.innerData.find(element => pattern.test(element[0]));
Expand Down

0 comments on commit 8d3ff8b

Please sign in to comment.