Mercurial > hg > cmmr2012-drupal-site
comparison core/misc/drupalSettingsLoader.es6.js @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 /** | |
2 * @file | |
3 * Parse inline JSON and initialize the drupalSettings global object. | |
4 */ | |
5 | |
6 (function () { | |
7 // Use direct child elements to harden against XSS exploits when CSP is on. | |
8 const settingsElement = document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]'); | |
9 | |
10 /** | |
11 * Variable generated by Drupal with all the configuration created from PHP. | |
12 * | |
13 * @global | |
14 * | |
15 * @type {object} | |
16 */ | |
17 window.drupalSettings = {}; | |
18 | |
19 if (settingsElement !== null) { | |
20 window.drupalSettings = JSON.parse(settingsElement.textContent); | |
21 } | |
22 }()); |