fix: 解决forEach的兼容性问题 (#199)

This commit is contained in:
Zhicheng Wang 2017-03-03 15:59:35 +08:00
parent b735266b94
commit 4df9030215

View File

@ -19,7 +19,8 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
*/ */
function processContainer(container) { function processContainer(container) {
var nodes = container.querySelectorAll('p,h1,h2,h3,h4,h5,h6,header,a'); var nodes = container.querySelectorAll('p,h1,h2,h3,h4,h5,h6,header,a');
nodes.forEach((node)=> { for(var i in nodes) {
(function(node) {
if (isTranslation(node.textContent)) { if (isTranslation(node.textContent)) {
var $translated = $(node); var $translated = $(node);
var prevNode = node.previousElementSibling; var prevNode = node.previousElementSibling;
@ -38,7 +39,8 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
}); });
} }
} }
}); })(nodes[i]);
}
} }
function isTranslation(text) { function isTranslation(text) {