You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/10/29 11:05:34 UTC
[incubator-echarts] 01/02: test: fix nth child query in recorder
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch add-test-interactions
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 484f9ae99f2749f834f6d26b3b16fe4ab3228d75
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Oct 29 12:57:12 2020 +0800
test: fix nth child query in recorder
---
test/runTest/recorder/recorder.js | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/test/runTest/recorder/recorder.js b/test/runTest/recorder/recorder.js
index 3d4fe62..66f18de 100644
--- a/test/runTest/recorder/recorder.js
+++ b/test/runTest/recorder/recorder.js
@@ -23,13 +23,15 @@ function getNthChild(el) {
let i = 1;
let elTagName = el.tagName;
let elClassName = el.className;
+ let nthSameClass = 1;
while (el.previousSibling) {
el = el.previousSibling;
- if (el.tagName === elTagName && el.className === elClassName) { // TODO extra space in class name?
- i++;
+ if (el.tagName === elTagName && el.className === elClassName) {
+ nthSameClass++;
}
+ i++;
}
- return i;
+ return [i, nthSameClass];
}
function getUniqueSelector(el) {
if (el.tagName.toLowerCase() === 'body') {
@@ -45,8 +47,8 @@ function getUniqueSelector(el) {
for (let className of el.classList) {
selector += '.' + className;
}
- let idx = getNthChild(el);
- if (idx > 1) {
+ let [idx, nthSameClass] = getNthChild(el);
+ if (nthSameClass > 1) {
selector += `:nth-child(${idx})`;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org