Skip to content
Browse files

commonRange改名为更语义化的cachedRange

  • Loading branch information...
1 parent 5a72545 commit a8669463765d1690dabe20623699f8a09ff83616 @RubyLouvre committed Mar 6, 2013
Showing with 51 additions and 45 deletions.
  1. +45 −39 index.html
  2. +3 −3 node.js
  3. +2 −2 node_neo.js
  4. +1 −1 support.js
View
84 index.html
@@ -3,54 +3,60 @@
<html>
<head>
<title></title>
+ <link href="aa" type="text/css" rel="stylesheet" charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试</title>
<style>
-
+
</style>
- <script src="mass.js"></script>
+ <script src="mass.js"></script>
<script>
- require("class,node", function($) {
-
- var Animal = $.factory({
- init: function(name) {
- this.name = name
- },
- getName: function() {
- return this.name;
- },
- setName: function(name) {
- this.name = name;
- }
- });
-
- var a = new Animal("zzz");
- var Dog = $.factory(Animal, {
- init: function(name, age) {
- this.age = age;
- },
- getAge: function() {
- return this.age;
- },
- setAge: function(age) {
- this.age = age;
- }
- });
-
- var dog = new Dog("dog",222);
-
- console.log(a);
- console.log(dog)
-
- })
+window.onload = function() {
+ var div = document.createElement("div");
+   div.innerHTML = '<table><tbody><tr></tr></tbody></table>';
+ //  alert(div.getElementsByTagName("tr").length); 
+ // div.innerHTML = '<table><tbody><tr></tr>'; 
+ // alert(div.getElementsByTagName("tr").length);
+ var a = document.body.insertAdjacentHTML("afterBegin", "<div>6666666</div>");
+ console.log(a)
+}
</script>
</head>
<body>
-
- <button onclick="">Test</button>
- <a href="aaa">司徒正美</a>
+ <div class="aaa bbb" >
+1111111
+ </div>
+ <div>
+ 2222222222
+ </div >
+ <div>
+ 33333333
+ </div>
+ <div>
+ 4444444444
+ </div>
+ <div>
+ 555555555
+ </div>
+ <div>
+ 6666666666666
+ </div>
+ <div>
+ 77777777
+ </div>
+ <div>
+ 888888888
+ </div>
+ <div>
+ 999999
+ </div>
+ <div>
+ 10
+ </div>
+ <div>
+ 11
+ </div>
</body>
-
</html>
View
6 node.js
@@ -310,8 +310,8 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
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)) {
- return $.commonRange.createContextualFragment(html);
+ if($.cachedRange && doc === document && !rcreate.test(html) && !rnest.test(html)) {
+ return $.cachedRange.createContextualFragment(html);
}
if($.support.noscope) { //fix IE
html = html.replace(rcreate, "<br class='fix_create_all'/>$1"); //在link style script等标签之前添加一个补丁
@@ -359,7 +359,7 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
thead: [1, "<table>", "</table>"],
tr: [2, "<table><tbody>"],
td: [3, "<table><tbody><tr>"],
- //IE678在用innerHTML生成节点时存在BUG,不能直接创建script,link,meta,style与HTML5的新标签
+ //IE6-8在用innerHTML生成节点时,不能直接创建no-scope元素与HTML5的新标签
_default: $.support.noscope? [1, "X<div>"] :[0, ""] //div可以不用闭合
},
insertHooks = {
View
4 node_neo.js
@@ -306,8 +306,8 @@ 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 && !rnest.test(html)) {
- return $.commonRange.createContextualFragment(html);
+ if ($.cachedRange && doc === document && !rnest.test(html)) {
+ return $.cachedRange.createContextualFragment(html);
}
var tag = (rtagName.exec(html) || ["", ""])[1].toLowerCase(),
View
2 support.js
@@ -101,7 +101,7 @@ define("support", ["mass"], function($) {
var range = DOC.createRange();
range.selectNodeContents(body); //fix opera(9.2~11.51) bug,必须对文档进行选取
support.fastFragment = !! range.createContextualFragment("<a>");
- $.commonRange = range;
+ $.cachedRange = range;
} catch(e) {};
div.style.cssText = "position:absolute;top:-1000px;left:-1000px;"
body.insertBefore(div, body.firstChild);

0 comments on commit a866946

Please sign in to comment.
Something went wrong with that request. Please try again.