mass的domReady方案
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mass的domReady方案相关的知识,希望对你有一定的参考价值。
mass框架的domReady解决方案
1 //mass的domReady方案 2 var readyList = []; 3 mass.ready = function(fn) { 4 if (readyList) { 5 fn.push(fn); 6 } else { 7 fn(); 8 } 9 } 10 var readyFn, ready = W3C ? "DOMContentLoaded" : "readystatechange"; 11 function fireReady() { 12 for (var i = 0, fn; fn = readyList[i++]; ) { 13 fn(); 14 } 15 readyList = null; 16 fireReady = $.noop; //惰性函数,防止IE9二次调用_checkDeps 17 } 18 19 function doScrollCheck() { 20 try { //IE下通过doScrollCheck检测DOM树是否建完 21 html.doScroll("left"); 22 fireReady(); 23 } catch (e) { 24 setTimeout(doScrollCheck); 25 } 26 } 27 28 //在Firefix3.6之前,不存在readyState属性 29 if (!DOC.readyState) { 30 var readyState = DOC.readyState = DOC.body ? "complete" : "loading"; 31 } 32 if (DOC.readyState === "complete") { 33 fireReady(); //如果在domReady之外加载 34 } else { 35 $.bind(DOC, ready, readyFn = function() { 36 if (W3C || DOC.readyState === "complete") { 37 fireReady(); 38 if (readyState) { //IE下不能改写DOC.readyState 39 DOC.readyState = "complete"; 40 } 41 } 42 }); 43 if (html.doScroll) { 44 try { //如果跨域会报错,那时肯定证明是存在两个窗口的 45 if (self.eavl === parent.eval) { 46 doScrollCheck(); 47 } 48 } catch (e) { 49 doScrollCheck(); 50 } 51 } 52 }
以上是关于mass的domReady方案的主要内容,如果未能解决你的问题,请参考以下文章
Mass Assignment: Insecure Binder Configuration Vulnerability 的解决方案是啥?