We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.6.0
问题场景如下图:
报错如下:
原因: 展开按钮需要查询展开节点的上下相邻节点,但这种场景下展开节点的prevLineNode是评论节点,所以获取不到prevLineNumber(parseInt(prevLineNode.children[0].innerText))
解决方案:
// vue-devui/packages/devui-vue/devui/code-review/src/utils.ts // 优化该方法,防止节点找不到的情况下报错 // 中间行展开后,折叠行数小于阈值时,将向上向下展开按钮更新为全部展开 export function updateExpandUpDownButton(trNode: HTMLElement) { trNode.children[0]?.children[0]?.remove(); trNode.children[0]?.children[0]?.classList.remove('up-expand'); trNode.children[0]?.children[0]?.classList.add('all-expand'); trNode.children[0]?.children[0] && (trNode.children[0].children[0].innerHTML = AllExpandIcon()); } // 新增以下两个方法,递归查找上一个或者下一个可以获取到左边行号的节点 /** * 查找给定节点的前一个同级元素节点。 * 适用于下一行是新增行或者删除行的情况 * * @param _node 如果折叠行后一行左边获取不到行数,则寻找第一个左边有行数的行。 * @returns 返回找到的后一个同级元素节点,如果没有找到则返回null。 */ export function findNextElement(_node: Element): Element { if (_node.children[0]?.innerText) { return _node; } return findNextElement(_node.nextElementSibling); } /** * 查找给定节点的前一个同级元素节点。 * 适用于上一行是新增行或者删除行或者评论行的情况 * * @param _node 如果折叠行后一行左边获取不到行数,则寻找第一个左边有行数的行。 * @returns 返回找到的前一个同级元素节点,如果没有找到则返回null。 */ export function findPrevElement(_node: Element): Element { if (_node.children[0]?.innerText) { return _node; } return findPrevElement(_node.previousElementSibling); } // 修改下面方法中各个判断条件里获取nextLineNode 和 prevLineNode的方法 export function updateLineNumberInDatasetForDoubleColumn(...省略掉) { const nextLineNode = findNextElement(trNode.nextElementSibling) as HTMLElement; const prevLineNode = findPrevElement(trNode.previousElementSibling) as HTMLElement; // 这里调用 updateExpandUpDownButton 这个方法有点多此一举,可以直接隐藏该节点即可 if (isExpandAll && updateExpandButton) { trNode.style.display = 'none'; // updateExpandUpDownButton(trNode); } }
No response
The text was updated successfully, but these errors were encountered:
[已提交]#1773
Sorry, something went wrong.
No branches or pull requests
Version
1.6.0
Vue Version
1.6.0
Link to minimal reproduction
Step to reproduce
问题场景如下图:
报错如下:
原因:
展开按钮需要查询展开节点的上下相邻节点,但这种场景下展开节点的prevLineNode是评论节点,所以获取不到prevLineNumber(parseInt(prevLineNode.children[0].innerText))
解决方案:
What is expected
No response
What is actually happening
No response
Any additional comments (optional)
No response
The text was updated successfully, but these errors were encountered: