Skip to content

Commit e13712c

Browse files
committed
Make attribute callbacks only work on a registered code-input element, so not trying to access pre/code/textarea element before
1 parent e268ada commit e13712c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

code-input.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@ var codeInput = {
604604
setup() {
605605
if(this.textareaElement != null) return; // Already set up
606606

607+
this.mutationObserver = new MutationObserver(this.mutationObserverCallback.bind(this));
608+
this.mutationObserver.observe(this, {
609+
attributes: true,
610+
attributeOldValue: true
611+
});
612+
607613
this.classList.add("code-input_registered"); // Remove register message
608614
if (this.templateObject.preElementStyled) this.classList.add("code-input_pre-element-styled");
609615

@@ -762,12 +768,7 @@ var codeInput = {
762768
this.classList.add("code-input_registered");
763769
this.setup();
764770
this.classList.add("code-input_loaded");
765-
}
766-
this.mutationObserver = new MutationObserver(this.mutationObserverCallback.bind(this));
767-
this.mutationObserver.observe(this, {
768-
attributes: true,
769-
attributeOldValue: true
770-
});
771+
}
771772
}
772773

773774
mutationObserverCallback(mutationList, observer) {

0 commit comments

Comments
 (0)