@@ -11,12 +11,12 @@ function CodeBox(elem) {
1111 Prism . highlightElement ( codeElem ) ;
1212 addLineNumbers ( preElem ) ;
1313
14- addBlockHighlight ( preElem , elem . dataset . highlightBlock ) ;
15- addInlineHighlight ( preElem , elem . dataset . highlightInline ) ;
14+ addBlockHighlight ( preElem , elem . getAttribute ( 'data-highlight-block' ) ) ;
15+ addInlineHighlight ( preElem , elem . getAttribute ( 'data-highlight-inline' ) ) ;
1616
1717 var isJS = preElem . classList . contains ( 'language-javascript' ) ;
1818 var isHTML = preElem . classList . contains ( 'language-markup' ) ;
19- var isTrusted = elem . dataset . trusted ;
19+ var isTrusted = + elem . getAttribute ( 'data- trusted' ) ;
2020 var jsFrame ;
2121 var htmlResult ;
2222 var isFirstRun = true ;
@@ -42,12 +42,12 @@ function CodeBox(elem) {
4242 }
4343
4444 // some code can't be shown by epub engine
45- if ( elem . dataset . autorun !== undefined ) {
46- if ( window . ebookType == 'epub' && elem . dataset . autorun == 'no-epub' ) {
45+ if ( elem . hasAttribute ( 'data- autorun' ) ) {
46+ if ( window . ebookType == 'epub' && elem . getAttribute ( 'data- autorun' ) == 'no-epub' ) {
4747 elem . querySelector ( 'iframe' ) . remove ( ) ;
4848 } else {
4949 // timeout should be small, around 10ms, or remove it to make crawler process the autorun
50- run ( ) ;
50+ setTimeout ( run , 100 ) ;
5151 }
5252 }
5353
@@ -64,7 +64,7 @@ function CodeBox(elem) {
6464
6565 var frame ;
6666
67- if ( htmlResult && elem . dataset . refresh ) {
67+ if ( htmlResult && elem . hasAttribute ( 'data- refresh' ) ) {
6868 htmlResult . remove ( ) ;
6969 htmlResult = null ;
7070 }
@@ -83,11 +83,11 @@ function CodeBox(elem) {
8383 frame . name = 'frame-' + Math . random ( ) ;
8484 frame . className = 'code-result__iframe' ;
8585
86- if ( elem . dataset . demoHeight === "0" ) {
86+ if ( elem . getAttribute ( 'data-demo-height' ) === "0" ) {
8787 // this html has nothing to show
8888 frame . style . display = 'none' ;
89- } else if ( elem . dataset . demoHeight ) {
90- var height = + elem . dataset . demoHeight ;
89+ } else if ( elem . hasAttribute ( 'data-demo-height' ) ) {
90+ var height = + elem . getAttribute ( 'data-demo-height' ) ;
9191 frame . style . height = height + 'px' ;
9292 }
9393 htmlResult . appendChild ( frame ) ;
@@ -118,11 +118,11 @@ function CodeBox(elem) {
118118 } , 2000 ) ;
119119 }
120120
121- if ( elem . dataset . demoHeight === undefined ) {
121+ if ( ! elem . hasAttribute ( 'data-demo-height' ) ) {
122122 resizeOnload . iframe ( frame ) ;
123123 }
124124
125- if ( ! ( isFirstRun && elem . dataset . autorun !== undefined ) ) {
125+ if ( ! ( isFirstRun && elem . hasAttribute ( 'data- autorun' ) ) ) {
126126 if ( ! isScrolledIntoView ( htmlResult ) ) {
127127 htmlResult . scrollIntoView ( false ) ;
128128 }
@@ -145,10 +145,10 @@ function CodeBox(elem) {
145145 form . submit ( ) ;
146146 form . remove ( ) ;
147147
148- if ( ! ( isFirstRun && elem . dataset . autorun !== undefined ) ) {
148+ if ( ! ( isFirstRun && elem . hasAttribute ( 'data- autorun' ) ) ) {
149149 frame . onload = function ( ) {
150150
151- if ( elem . dataset . demoHeight === undefined ) {
151+ if ( ! elem . hasAttribute ( 'data-demo-height' ) ) {
152152 resizeOnload . iframe ( frame ) ;
153153 }
154154
@@ -170,14 +170,12 @@ function CodeBox(elem) {
170170 window [ "eval" ] . call ( window , code ) ;
171171 } catch ( e ) {
172172 console . error ( e ) ;
173-
174173 alert ( "Ошибка: " + e . message ) ;
175- alert ( e . stack . split ( "\n" ) . slice ( 4 ) ) ;
176174 }
177175
178176 } else {
179177
180- if ( elem . dataset . refresh && jsFrame ) {
178+ if ( elem . hasAttribute ( 'data- refresh' ) && jsFrame ) {
181179 jsFrame . remove ( ) ;
182180 jsFrame = null ;
183181 }
0 commit comments