From 257b56caaef874eaecd713bc032144a132d25618 Mon Sep 17 00:00:00 2001 From: issaTan Date: Tue, 15 Aug 2017 18:42:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fixed=20=E5=9B=BE=E7=89=87=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. \n 去掉了,但是\r 留着,整个nodes 还是很大 2. 其实图片大小不正确的最主要原因是因为当node为text 的时候,没有index,所以后面calMoreImageInfo 时设置with/height 使用index来定位会出错;如果只是trimHtml的话,当真的有text 节点,图片宽高还是会有问题 --- wxParse/html2json.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wxParse/html2json.js b/wxParse/html2json.js index 184df06..2e1c739 100755 --- a/wxParse/html2json.js +++ b/wxParse/html2json.js @@ -55,7 +55,7 @@ function removeDOCTYPE(html) { function trimHtml(html) { return html - .replace(/\n+/g, '') + .replace(/\r?\n+/g, '') .replace(//ig, '') .replace(/\/\*.*?\*\//ig, '') .replace(/[ ]+ Date: Tue, 22 Aug 2017 10:09:12 +0800 Subject: [PATCH 2/2] fixed bug --- wxParse/html2json.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxParse/html2json.js b/wxParse/html2json.js index 2e1c739..1e8c188 100755 --- a/wxParse/html2json.js +++ b/wxParse/html2json.js @@ -205,7 +205,7 @@ function html2json(html, bindName) { //当有缓存source资源时于于video补上src资源 if(node.tag === 'video' && results.source){ node.attr.src = results.source; - delete result.source; + delete results.source; } if (bufArray.length === 0) {