Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions code-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,12 @@ var codeInput = {
if (this.templateObject != undefined) {
// Template registered before loading
this.classList.add("code-input_registered");
// Children not yet present - wait until they are
window.addEventListener("DOMContentLoaded", this.setup.bind(this))
if (document.readyState === 'loading') {
// Children not yet present - wait until they are
window.addEventListener("DOMContentLoaded", this.setup.bind(this))
} else {
this.setup();
}
}
}

Expand All @@ -859,7 +863,9 @@ var codeInput = {
}

disconnectedCallback() {
this.mutationObserver.disconnect();
if (this.mutationObserver) {
this.mutationObserver.disconnect();
}
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ console.log("I've got another line!", 2 < 3, "should be true.");`);
console.log("I've got another line!", 2 &lt; 3, "should be true.");
`); // Extra newline so line numbers visible if enabled

const programmaticCodeInput = document.createElement("code-input");
document.body.append(programmaticCodeInput);
programmaticCodeInput.focus();
document.execCommand("insertText", false, "Hello, World!");
assertEqual("Core", "Programmatically-created element JS-accessible value", programmaticCodeInput.value, "Hello, World!");
await waitAsync(50);
assertEqual("Core", "Programmatically-created element rendered value", programmaticCodeInput.preElement.textContent, "Hello, World!\n");

// Event Listener Tests
// Function type listeners
let numTimesInputCalled = 0;
Expand Down