Fix jupyter rendering bug that ended in an infinite loop

This commit is contained in:
ROSPARS Benoit 2019-03-27 13:03:30 +01:00
parent 0610bb0917
commit f620c69acc
2 changed files with 20 additions and 14 deletions

View File

@ -20,12 +20,20 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
outputType: '',
};
},
methods: { methods: {
outputType(output) {
if (output.text) {
return 'text/plain';
} else if (output.data['image/png']) {
return 'image/png';
} else if (output.data['text/html']) {
return 'text/html';
} else if (output.data['image/svg+xml']) {
return 'image/svg+xml';
}
return 'text/plain';
},
dataForType(output, type) { dataForType(output, type) {
let data = output.data[type]; let data = output.data[type];
@ -39,20 +47,13 @@ export default {
if (output.text) { if (output.text) {
return CodeOutput; return CodeOutput;
} else if (output.data['image/png']) { } else if (output.data['image/png']) {
this.outputType = 'image/png';
return ImageOutput; return ImageOutput;
} else if (output.data['text/html']) { } else if (output.data['text/html']) {
this.outputType = 'text/html';
return HtmlOutput; return HtmlOutput;
} else if (output.data['image/svg+xml']) { } else if (output.data['image/svg+xml']) {
this.outputType = 'image/svg+xml';
return HtmlOutput; return HtmlOutput;
} }
this.outputType = 'text/plain';
return CodeOutput; return CodeOutput;
}, },
rawCode(output) { rawCode(output) {
@ -60,7 +61,7 @@ export default {
return output.text.join(''); return output.text.join('');
} }
return this.dataForType(output, this.outputType); return this.dataForType(output, this.outputType(output));
}, },
}, },
}; };
@ -73,7 +74,7 @@ export default {
v-for="(output, index) in outputs" v-for="(output, index) in outputs"
:key="index" :key="index"
type="output" type="output"
:output-type="outputType" :output-type="outputType(output)"
:count="count" :count="count"
:index="index" :index="index"
:raw-code="rawCode(output)" :raw-code="rawCode(output)"

View File

@ -0,0 +1,5 @@
---
title: Fix jupyter rendering bug that ended in an infinite loop
merge_request: 26656
author: ROSPARS Benoit
type: fixed