Skip to content

Commit daf0cc0

Browse files
committed
Bug fix for update function call at start
1 parent b8ceb7d commit daf0cc0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

code-input.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ var codeInput = {
7171
// Prevent this from running multiple times on the same input when "value" attribute is changed,
7272
// by not running when value is already equal to the input of this (implying update has already
7373
// been run). Thank you to peterprvy for this.
74-
if(this.value == text) return;
74+
if(this.ignoreValueUpdate) return;
7575

7676
console.log("Update", text);
77-
77+
this.ignoreValueUpdate = true;
7878
this.value = text; // Change value attribute if necessary.
79-
if(this.querySelector("textarea").value != text) this.querySelector("textarea").value = text;
79+
this.ignoreValueUpdate = false;
80+
if(this.querySelector("textarea").value != text) this.queryS
81+
this.querySelector("textarea").value = text;
8082

8183

8284
let result_element = this.querySelector("pre code");
@@ -217,7 +219,7 @@ var codeInput = {
217219
if(this.template.preElementStyled) this.classList.add("code-input_pre-element-styled");
218220
else this.classList.remove("code-input_pre-element-styled");
219221
// Syntax Highlight
220-
this.update(this.value);
222+
this.update(this.value, true);
221223

222224
break;
223225

0 commit comments

Comments
 (0)