Mercurial > hg > isophonics-drupal-site
annotate core/misc/drupalSettingsLoader.es6.js @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@0 | 1 /** |
Chris@0 | 2 * @file |
Chris@0 | 3 * Parse inline JSON and initialize the drupalSettings global object. |
Chris@0 | 4 */ |
Chris@0 | 5 |
Chris@17 | 6 (function() { |
Chris@0 | 7 // Use direct child elements to harden against XSS exploits when CSP is on. |
Chris@17 | 8 const settingsElement = document.querySelector( |
Chris@17 | 9 'head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]', |
Chris@17 | 10 ); |
Chris@0 | 11 |
Chris@0 | 12 /** |
Chris@0 | 13 * Variable generated by Drupal with all the configuration created from PHP. |
Chris@0 | 14 * |
Chris@0 | 15 * @global |
Chris@0 | 16 * |
Chris@0 | 17 * @type {object} |
Chris@0 | 18 */ |
Chris@0 | 19 window.drupalSettings = {}; |
Chris@0 | 20 |
Chris@0 | 21 if (settingsElement !== null) { |
Chris@0 | 22 window.drupalSettings = JSON.parse(settingsElement.textContent); |
Chris@0 | 23 } |
Chris@17 | 24 })(); |