Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from zalando-incubator/6-display-fix
Browse files Browse the repository at this point in the history
fix css & html issues
  • Loading branch information
mrandi authored Apr 24, 2018
2 parents ad0baa7 + 5ad951e commit ccd13d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/css/skeleton.css
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,8 @@ button:active {

#editorDiv {
height: 85%;
width: 100%;
display: inline-block;
}

#json-editor-input {
Expand Down
34 changes: 2 additions & 32 deletions src/ts/util/check-if-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,9 @@ function allTextNodes(nodes) {
function getPreWithSource() {
var childNodes = document.body.childNodes;

if (childNodes.length === 0) {
return null
if (childNodes.length === 1 && childNodes[0].nodeName === "PRE") {
return childNodes[0];
}

if (childNodes.length > 1 && allTextNodes(childNodes)) {
if (process.env.NODE_ENV === 'development') {
console.debug("[bro/q] Loaded from a multiple text nodes, normalizing");
}

document.body.normalize() // concatenates adjacent text nodes
}

var childNode = childNodes[0];
var nodeName = childNode.nodeName
var textContent = childNode.textContent

if (nodeName === "PRE") {
return childNode;
}

// if Content-Type is text/html
if (nodeName === "#text" && textContent.trim().length > 0) {
if (process.env.NODE_ENV === 'development') {
console.debug("[bro/q] Loaded from a text node, this might have returned content-type: text/html");
}

var pre = document.createElement("pre");
pre.textContent = textContent;
document.body.removeChild(childNode);
document.body.appendChild(pre);
return pre;
}

return null
}

Expand Down

0 comments on commit ccd13d8

Please sign in to comment.