Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

_ready函数在DOMContentLoaded事件就绪后document.readyState === 'complete'没有执行readyFunc #346

Open
GitHub-MXB opened this issue Nov 17, 2023 · 0 comments

Comments

@GitHub-MXB
Copy link

	function _ready(fn) {
		ieReadyStateFunc();   //应该执行这个
		if (_readyFinished) {  //替换此代码
			fn(KindEditor);
			return;
		}
		var loaded = false;
		function readyFunc() {
			if (!loaded) {
				loaded = true;
				fn(KindEditor);
				_readyFinished = true;
			}
		}
		function ieReadyFunc() {
			if (!loaded) {
				try {
					document.documentElement.doScroll('left');
				} catch (e) {
					setTimeout(ieReadyFunc, 100);
					return;
				}
				readyFunc();
			}
		}
		function ieReadyStateFunc() {
			if (document.readyState === 'complete') {
				readyFunc();
			}
		}
		if (document.addEventListener) {
			_bind(document, 'DOMContentLoaded', readyFunc);
		} else if (document.attachEvent) {
			_bind(document, 'readystatechange', ieReadyStateFunc);
			var toplevel = false;
			try {
				toplevel = window.frameElement == null;
			} catch (e) { }
			if (document.documentElement.doScroll && toplevel) {
				ieReadyFunc();
			}
		}
		_bind(window, 'load', readyFunc);
	}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant