fix: 自动把中文元素的id设置为相应英文元素的

This commit is contained in:
Zhicheng Wang 2017-03-03 16:39:36 +08:00
parent 3dfa29b36d
commit 2a60ad27a7
2 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,7 @@ a(id='toc')
1. [Single responsibility](#single-responsibility)
[单一职责](#single-responsibility)
1. [Naming](#naming)
[命名](#naming)
@ -95,6 +96,7 @@ a(id='toc')
1. [App structure and Angular modules](#application-structure-and-angular-modules)
[应用结构与 Angular 模块](#app-structure-and-angular-modules)
1. [Components](#components)
[组件](#components)
@ -114,6 +116,7 @@ a(id='toc')
1. [Lifecycle hooks](#lifecycle-hooks)
[生命周期钩子](#lifecycle-hooks)
1. [Appendix](#appendix)
[附录](#appendix)

View File

@ -30,6 +30,11 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
var prevNode = node.previousElementSibling;
var $english = $(prevNode);
if (isCorrespondingNode(node, prevNode) && !isTranslation(prevNode.textContent)) {
var id = $english.attr('id');
if (id) {
$translated.attr('id', id);
$english.removeAttr('id');
}
$translated.after($english);
$translated.addClass('translated');
$translated.addClass('translated-cn');