From fc75d9881dc44c8f1779c16d0221895a584ae2ec Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 27 May 2020 16:57:16 +0530 Subject: [PATCH] Initialized existing members.js data attribute handling refs https://github.com/TryGhost/members.js/issues/32 - Inits data attribute handling from the copied over members.js file from core - Uses `window.location.origin` as site url for api calls in data attribute handling --- ghost/portal/src/data-attributes.js | 2 ++ ghost/portal/src/index.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ghost/portal/src/data-attributes.js b/ghost/portal/src/data-attributes.js index 18775d977f..163df63f3a 100644 --- a/ghost/portal/src/data-attributes.js +++ b/ghost/portal/src/data-attributes.js @@ -1,3 +1,5 @@ +/* eslint-disable no-console */ + function handleDataAttributes({siteUrl}) { Array.prototype.forEach.call(document.querySelectorAll('form[data-members-form]'), function (form) { let errorEl = form.querySelector('[data-members-error]'); diff --git a/ghost/portal/src/index.js b/ghost/portal/src/index.js index d1cc2ca432..8e3152f259 100644 --- a/ghost/portal/src/index.js +++ b/ghost/portal/src/index.js @@ -3,6 +3,8 @@ import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; +const handleDataAttributes = require('./data-attributes'); + function addRootDiv() { const elem = document.createElement('div'); elem.id = 'ghost-membersjs-root'; @@ -19,6 +21,7 @@ function handleTokenUrl() { function init() { addRootDiv(); + handleDataAttributes({siteUrl: window.location.origin}); handleTokenUrl(); ReactDOM.render(