@financial-times/n-myft-ui 30.0.0 → 30.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,7 @@
17
17
  "js-cookie": "^2.2.1",
18
18
  "next-myft-client": "^10.3.0",
19
19
  "next-session-client": "^4.0.0",
20
+ "ready-state": "^2.0.5",
20
21
  "superstore-sync": "^2.1.1"
21
22
  },
22
23
  "devDependencies": {
@@ -18554,6 +18555,11 @@
18554
18555
  "node": ">=0.10"
18555
18556
  }
18556
18557
  },
18558
+ "node_modules/ready-state": {
18559
+ "version": "2.0.5",
18560
+ "resolved": "https://registry.npmjs.org/ready-state/-/ready-state-2.0.5.tgz",
18561
+ "integrity": "sha512-rwuszAC+hAAhQWK0alQOSq0Fa5/SO9XvbzVY/Ki82d1ocwLY7kdjEooVbYg7GELrCXySckTmsuTgLd8hqKz9Og=="
18562
+ },
18557
18563
  "node_modules/rechoir": {
18558
18564
  "version": "0.7.1",
18559
18565
  "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz",
@@ -38860,6 +38866,11 @@
38860
38866
  "readable-stream": "^2.0.2"
38861
38867
  }
38862
38868
  },
38869
+ "ready-state": {
38870
+ "version": "2.0.5",
38871
+ "resolved": "https://registry.npmjs.org/ready-state/-/ready-state-2.0.5.tgz",
38872
+ "integrity": "sha512-rwuszAC+hAAhQWK0alQOSq0Fa5/SO9XvbzVY/Ki82d1ocwLY7kdjEooVbYg7GELrCXySckTmsuTgLd8hqKz9Og=="
38873
+ },
38863
38874
  "rechoir": {
38864
38875
  "version": "0.7.1",
38865
38876
  "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz",
@@ -8,10 +8,17 @@ import Delegate from 'ftdomdelegate';
8
8
  import personaliseLinks from '../personalise-links';
9
9
  import doFormSubmit from './do-form-submit';
10
10
  import enhanceActionUrls from './enhance-action-urls';
11
+ import readyState from 'ready-state';
11
12
 
12
- const delegate = new Delegate(document.body);
13
13
  let initialised;
14
14
 
15
+ function createDelegate (action, selector, cb) {
16
+ readyState.domready.then(() => {
17
+ const delegate = new Delegate(document.body);
18
+ delegate.on(action, selector, cb);
19
+ });
20
+ }
21
+
15
22
  function getInteractionHandler (relationshipName) {
16
23
  return (ev, formEl) => {
17
24
  ev.preventDefault();
@@ -29,7 +36,7 @@ function anonEventListeners () {
29
36
  };
30
37
 
31
38
  ['followed', 'saved'].forEach(action => {
32
- delegate.on('submit', relationshipConfig[action].uiSelector, event => {
39
+ createDelegate('submit', relationshipConfig[action].uiSelector, event => {
33
40
  event.preventDefault();
34
41
  nNotification.show({
35
42
  content: messages[action],
@@ -77,7 +84,7 @@ function signedInEventListeners () {
77
84
  });
78
85
  });
79
86
 
80
- delegate.on('submit', uiSelector, getInteractionHandler(relationshipName));
87
+ createDelegate('submit', uiSelector, getInteractionHandler(relationshipName));
81
88
  }
82
89
  });
83
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-myft-ui",
3
- "version": "30.0.0",
3
+ "version": "30.0.1",
4
4
  "description": "Client side component for interaction with myft",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -107,6 +107,7 @@
107
107
  "js-cookie": "^2.2.1",
108
108
  "next-myft-client": "^10.3.0",
109
109
  "next-session-client": "^4.0.0",
110
+ "ready-state": "^2.0.5",
110
111
  "superstore-sync": "^2.1.1"
111
112
  },
112
113
  "volta": {