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
8 changes: 3 additions & 5 deletions src/ui/public/metadata.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import $ from 'jquery';
import _ from 'lodash';
// singleton for immutable copy of window.__KBN__

if (!_.has(window, '__KBN__')) {
throw new Error('window.__KBN__ must be set for metadata');
}
const state = $('kbn-initial-state').attr('data');
const kbn = window.__KBN__ = JSON.parse(state);

const kbn = _.cloneDeep(window.__KBN__ || {});
export default deepFreeze(kbn);

function deepFreeze(object) {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/views/chrome.jade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- var j = function (o) { return JSON.stringify(o); }
- var appName = 'kibana';
-
var appName = 'kibana';

block vars

Expand All @@ -12,5 +12,5 @@ html(lang='en')
title Kibana
block head
body(kbn-chrome, id='#{appName}-body')
script window.__KBN__ = !{j(kibanaPayload)};
kbn-initial-state(data=JSON.stringify(kibanaPayload))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the !{} can just be replaced with #{} to use jade's default escaping?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. That'd turn JSON into " and stuff. It HTML-encodes.

block content