diff --git a/src/components/Editor.vue b/src/components/Editor.vue
index 61bd3c9..2289ff6 100644
--- a/src/components/Editor.vue
+++ b/src/components/Editor.vue
@@ -120,7 +120,7 @@ export default {
},
computed: {
content() {
- return prism(this.codeData, this.language);
+ return prism(this.codeData || "", this.language);
},
lineNumbersCount() {
let totalLines = this.codeData.split(/\r\n|\n/).length;
@@ -346,6 +346,10 @@ export default {
}
}
+ if (!this.code) {
+ this.codeData = evt.target.innerText;
+ }
+
if (this.emitEvents) {
this.$emit("keyup", evt);
}
diff --git a/tests/unit/Editor.spec.js b/tests/unit/Editor.spec.js
index d0a7bca..cad9010 100644
--- a/tests/unit/Editor.spec.js
+++ b/tests/unit/Editor.spec.js
@@ -53,6 +53,17 @@ describe("Editor.vue", () => {
expect(wrapper.vm.code).toEqual("works");
});
+ it("works without v-model", () => {
+ const wrapper = mount(Editor, {
+ emitEvents: true
+ });
+
+ wrapper.vm.codeData = "";
+ expect(wrapper.vm.content).toBe(
+ `<html>
`
+ );
+ });
+
it("code with sync modifier works", () => {
const compiled = compileToFunctions(
'