Permalink
Browse files

upate parseHTML

  • Loading branch information...
1 parent f9ad038 commit 5a725458a2d7c1f6cecf2879725f6838ae363313 @RubyLouvre committed Mar 6, 2013
Showing with 3 additions and 4 deletions.
  1. +1 −1 node.js
  2. +2 −3 node_neo.js
View
2 node.js
@@ -313,7 +313,7 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
if($.commonRange && doc === document && !rcreate.test(html) && !rnest.test(html)) {
return $.commonRange.createContextualFragment(html);
}
- if(!$.support.createAll) { //fix IE
+ if($.support.noscope) { //fix IE
html = html.replace(rcreate, "<br class='fix_create_all'/>$1"); //在link style script等标签之前添加一个补丁
}
var tag = (rtagName.exec(html) || ["", ""])[1].toLowerCase(),
View
5 node_neo.js
@@ -6,7 +6,6 @@ define("node", ["support", "class", "query", "data"], function($) {
rtagName = /<([\w:]+)/,
//取得其tagName
rxhtml = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
- rcreate = $.support.createAll ? /<(?:script)/ig : /(<(?:script|link|style))/ig,
types = $.oneObject("text/javascript", "text/ecmascript", "application/ecmascript", "application/javascript", "text/vbscript"),
//需要处理套嵌关系的标签
rnest = /<(?:tb|td|tf|th|tr|col|opt|leg|cap|area)/,
@@ -141,7 +140,7 @@ define("node", ["support", "class", "query", "data"], function($) {
//接着判断innerHTML属性是否符合标准,不再区分可读与只读
//用户传参是否包含了script style meta等不能用innerHTML直接进行创建的标签
//及像col td map legend等需要满足套嵌关系才能创建的标签, 否则会在IE与safari下报错
- if ($.support.innerHTML && (!rcreate.test(value) && !rnest.test(value))) {
+ if ($.support.innerHTML && !rnest.test(value)) {
try {
for (var i = 0; el = this[i++]; ) {
if (el.nodeType === 1) {
@@ -307,7 +306,7 @@ define("node", ["support", "class", "query", "data"], function($) {
html = html.replace(rxhtml, "<$1></$2>").trim();
//尝试使用createContextualFragment获取更高的效率
//http://www.cnblogs.com/rubylouvre/archive/2011/04/15/2016800.html
- if ($.commonRange && doc === document && !rcreate.test(html) && !rnest.test(html)) {
+ if ($.commonRange && doc === document && !rnest.test(html)) {
return $.commonRange.createContextualFragment(html);
}

0 comments on commit 5a72545

Please sign in to comment.