mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-29 14:10:47 +08:00
perf(vue): refer native script source code to reduce number of loops
* perf(vue,vue-next): refer native script to reduce number of loops
* Revert "perf(vue,vue-next): refer native script to reduce number of loops"
This reverts commit 7add201a32.
* perf(vue,vue-next): refer native script to reduce number of loops
Co-authored-by: Zoom Chan <zoom_chan@163.com>
This commit is contained in:
committed by
Zoom Chan
co-authored by
Zoom Chan
parent
ed86866cf6
commit
c09818baef
@@ -462,24 +462,36 @@ class Selector extends SelectorCore {
|
||||
let siblingGroup = [];
|
||||
let lastGroup = [];
|
||||
const groups = [];
|
||||
const reverseSelectors = [...selectors].reverse();
|
||||
reverseSelectors.forEach((sel) => {
|
||||
const selectorList = [...selectors];
|
||||
const length = selectorList.length - 1;
|
||||
this.specificity = 0;
|
||||
this.dynamic = false;
|
||||
|
||||
for (let i = length; i >= 0; i--) {
|
||||
const sel = selectorList[i];
|
||||
if (supportedCombinator.indexOf(sel.combinator) === -1) {
|
||||
console.error(`Unsupported combinator "${sel.combinator}".`);
|
||||
throw new Error(`Unsupported combinator "${sel.combinator}".`);
|
||||
}
|
||||
|
||||
if (sel.combinator === undefined || sel.combinator === ' ') {
|
||||
groups.push(lastGroup = [(siblingGroup = [])]);
|
||||
}
|
||||
if (sel.combinator === '>') {
|
||||
lastGroup.push(siblingGroup = []);
|
||||
lastGroup.push((siblingGroup = []));
|
||||
}
|
||||
|
||||
this.specificity += sel.specificity;
|
||||
|
||||
if (sel.dynamic) {
|
||||
this.dynamic = true;
|
||||
}
|
||||
|
||||
siblingGroup.push(sel);
|
||||
});
|
||||
this.groups = groups.map(g => new Selector.ChildGroup(g.map(sg => new Selector.SiblingGroup(sg))));
|
||||
this.last = reverseSelectors[0];
|
||||
this.specificity = reverseSelectors.reduce((sum, sel) => sel.specificity + sum, 0);
|
||||
this.dynamic = reverseSelectors.some(sel => sel.dynamic);
|
||||
}
|
||||
|
||||
this.groups = groups.map(g => new ChildGroup(g.map(sg => new SiblingGroup(sg))));
|
||||
this.last = selectorList[length];
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
Reference in New Issue
Block a user