소스 검색

BugFix: check pageEditorDom is defined (should abort when admin page)

Yuki Takei 8 년 전
부모
커밋
b79b5374c1
1개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 9 1
      resource/js/legacy/crowi.js

+ 9 - 1
resource/js/legacy/crowi.js

@@ -71,11 +71,19 @@ Crowi.setCaretLineData = function(line) {
 }
 
 /**
- * invoked when 'shown.bs.tab' event fired
+ * invoked when;
+ *
+ * 1. window loaded
+ * 2. 'shown.bs.tab' event fired
  */
 Crowi.setCaretLineAndFocusToEditor = function() {
   // get 'data-caret-line' attributes
   const pageEditorDom = document.querySelector('#page-editor');
+
+  if (pageEditorDom == null) {
+    return;
+  }
+
   const line = pageEditorDom.getAttribute('data-caret-line');
 
   if (line != null) {