mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 Fixed missing location/referrer data with multiple {{subscribe_form}} (#9713)
no issue - replaced `querySelector` with `querySelectorAll` and a loop so that all subscribe form inputs have their values updated rather than only the first form on the page - made the selector more specific so that it only updates `<input>` elements - switched to a template string so it's easier to read/write
This commit is contained in:
parent
8c1061cd30
commit
7e105eb5b6
1 changed files with 13 additions and 7 deletions
|
@ -26,13 +26,19 @@ function makeHidden(name, extras) {
|
||||||
*
|
*
|
||||||
* document.querySelector['.location']['value'] = document.querySelector('.location')['value'] || window.location.href;
|
* document.querySelector['.location']['value'] = document.querySelector('.location')['value'] || window.location.href;
|
||||||
*/
|
*/
|
||||||
subscribeScript =
|
subscribeScript = `
|
||||||
'<script>' +
|
<script>
|
||||||
'(function(g,h,o,s,t){' +
|
(function(g,h,o,s,t){
|
||||||
'h[o](\'.location\')[s]=h[o](\'.location\')[s] || g.location.href;' +
|
var buster = function(b,m) {
|
||||||
'h[o](\'.referrer\')[s]=h[o](\'.referrer\')[s] || h.referrer;' +
|
h[o]('input.'+b).forEach(function (i) {
|
||||||
'})(window,document,\'querySelector\',\'value\');' +
|
i.value=i.value || m;
|
||||||
'</script>';
|
});
|
||||||
|
};
|
||||||
|
buster('location', g.location.href);
|
||||||
|
buster('referrer', h.referrer);
|
||||||
|
})(window,document,'querySelectorAll','value');
|
||||||
|
</script>
|
||||||
|
`;
|
||||||
|
|
||||||
// We use the name subscribe_form to match the helper for consistency:
|
// We use the name subscribe_form to match the helper for consistency:
|
||||||
module.exports = function subscribe_form(options) { // eslint-disable-line camelcase
|
module.exports = function subscribe_form(options) { // eslint-disable-line camelcase
|
||||||
|
|
Loading…
Add table
Reference in a new issue