We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a91fe2 commit 05f7c32Copy full SHA for 05f7c32
extension/src/json-viewer/check-if-json.js
@@ -1,9 +1,20 @@
1
var extractJSON = require('./extract-json');
2
3
+function allTextNodes(nodes) {
4
+ return Object.keys(nodes).reduce(function(result, key) {
5
+ return result && nodes[key].nodeName === '#text'
6
+ }, true)
7
+}
8
+
9
function getPreWithSource() {
10
var childNodes = document.body.childNodes;
11
12
if (childNodes.length > 1 && childNodes[0].nodeName === "#text"){
13
+ if (childNodes.length > 1 && allTextNodes(childNodes)) {
14
+ if (process.env.NODE_ENV === 'development') {
15
+ console.debug("[JSONViewer] Loaded from a multiple text nodes, normalizing");
16
+ }
17
18
document.body.normalize() // concatenates adjacent text nodes
19
}
20
0 commit comments