@wordpress/e2e-tests 8.1.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -3
- package/package.json +9 -9
- package/plugins/deprecated-node-matcher/index.js +1 -1
- package/plugins/hooks-api/index.js +1 -1
- package/plugins/iframed-block/jquery.test.js +2 -2
- package/plugins/iframed-block/script.js +0 -1
- package/plugins/iframed-enqueue-block-assets/script.js +2 -1
- package/plugins/iframed-masonry-block/editor.js +9 -3
- package/plugins/iframed-masonry-block/script.js +0 -1
- package/plugins/iframed-multiple-stylesheets/block.json +5 -1
- package/plugins/inner-blocks-allowed-blocks/index.js +10 -6
- package/plugins/inner-blocks-prioritized-inserter-blocks/index.js +36 -36
- package/plugins/inner-blocks-templates/index.js +63 -40
- package/plugins/interactive-blocks/directive-context/view.js +3 -4
- package/plugins/interactive-blocks/directive-each/view.js +44 -35
- package/plugins/interactive-blocks/directive-key/view.js +1 -1
- package/plugins/interactive-blocks/directive-on-document/view.js +2 -2
- package/plugins/interactive-blocks/directive-on-window/view.js +3 -3
- package/plugins/interactive-blocks/directive-priorities/view.js +6 -3
- package/plugins/interactive-blocks/directive-run/view.js +22 -18
- package/plugins/interactive-blocks/directive-text/view.js +2 -3
- package/plugins/interactive-blocks/directive-watch/view.js +3 -1
- package/plugins/interactive-blocks/namespace/view.js +0 -6
- package/plugins/interactive-blocks/router-navigate/view.js +3 -3
- package/plugins/interactive-blocks/router-regions/view.js +1 -1
- package/plugins/interactive-blocks/tovdom/cdata.js +1 -3
- package/plugins/interactive-blocks/with-scope/view.js +11 -7
- package/plugins/plugins-api/annotations-sidebar.js +6 -5
- package/plugins/plugins-api/error-boundary.js +1 -1
- package/plugins/test-autocompleter/index.js +4 -6
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 8.3.0 (2024-07-10)
|
6
|
+
|
7
|
+
## 8.2.0 (2024-06-26)
|
8
|
+
|
5
9
|
## 8.1.0 (2024-06-15)
|
6
10
|
|
7
11
|
## 8.0.0 (2024-05-31)
|
@@ -99,7 +103,7 @@
|
|
99
103
|
|
100
104
|
## 5.3.0 (2022-10-05)
|
101
105
|
|
102
|
-
### New
|
106
|
+
### New Features
|
103
107
|
|
104
108
|
- Added Autocomplete Component e2e test suite. [#42905](https://github.com/WordPress/gutenberg/pull/42905).
|
105
109
|
|
@@ -107,7 +111,7 @@
|
|
107
111
|
|
108
112
|
## 5.0.0 (2022-08-24)
|
109
113
|
|
110
|
-
### Breaking
|
114
|
+
### Breaking Changes
|
111
115
|
|
112
116
|
- Increase the minimum Node.js version to 14 ([#43141](https://github.com/WordPress/gutenberg/pull/43141)).
|
113
117
|
|
@@ -158,7 +162,7 @@
|
|
158
162
|
|
159
163
|
## 1.2.0 (2019-05-21)
|
160
164
|
|
161
|
-
### New
|
165
|
+
### New Features
|
162
166
|
|
163
167
|
- Added Axe (the Accessibility Engine) API integration with e2e tests suite.
|
164
168
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/e2e-tests",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.3.0",
|
4
4
|
"description": "End-To-End (E2E) tests for WordPress.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -24,13 +24,13 @@
|
|
24
24
|
"npm": ">=8.19.2"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@wordpress/e2e-test-utils": "^11.
|
28
|
-
"@wordpress/interactivity": "^6.
|
29
|
-
"@wordpress/interactivity-router": "^2.
|
30
|
-
"@wordpress/jest-console": "^8.
|
31
|
-
"@wordpress/jest-puppeteer-axe": "^7.
|
32
|
-
"@wordpress/scripts": "^28.
|
33
|
-
"@wordpress/url": "^4.
|
27
|
+
"@wordpress/e2e-test-utils": "^11.3.0",
|
28
|
+
"@wordpress/interactivity": "^6.3.0",
|
29
|
+
"@wordpress/interactivity-router": "^2.3.0",
|
30
|
+
"@wordpress/jest-console": "^8.3.0",
|
31
|
+
"@wordpress/jest-puppeteer-axe": "^7.3.0",
|
32
|
+
"@wordpress/scripts": "^28.3.0",
|
33
|
+
"@wordpress/url": "^4.3.0",
|
34
34
|
"chalk": "^4.0.0",
|
35
35
|
"expect-puppeteer": "^4.4.0",
|
36
36
|
"filenamify": "^4.2.0",
|
@@ -47,5 +47,5 @@
|
|
47
47
|
"publishConfig": {
|
48
48
|
"access": "public"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "122867d355ca4edc63d3a3bbd9411d3a2e1458df"
|
51
51
|
}
|
@@ -6,18 +6,24 @@
|
|
6
6
|
|
7
7
|
const content = [
|
8
8
|
el( 'div', { className: 'grid-item' } ),
|
9
|
-
el( 'div', {
|
9
|
+
el( 'div', {
|
10
|
+
className: 'grid-item grid-item--width2 grid-item--height2',
|
11
|
+
} ),
|
10
12
|
el( 'div', { className: 'grid-item grid-item--height3' } ),
|
11
13
|
el( 'div', { className: 'grid-item grid-item--height2' } ),
|
12
14
|
el( 'div', { className: 'grid-item grid-item--width3' } ),
|
13
15
|
el( 'div', { className: 'grid-item' } ),
|
14
16
|
el( 'div', { className: 'grid-item' } ),
|
15
17
|
el( 'div', { className: 'grid-item grid-item--height2' } ),
|
16
|
-
el( 'div', {
|
18
|
+
el( 'div', {
|
19
|
+
className: 'grid-item grid-item--width2 grid-item--height3',
|
20
|
+
} ),
|
17
21
|
el( 'div', { className: 'grid-item' } ),
|
18
22
|
el( 'div', { className: 'grid-item grid-item--height2' } ),
|
19
23
|
el( 'div', { className: 'grid-item' } ),
|
20
|
-
el( 'div', {
|
24
|
+
el( 'div', {
|
25
|
+
className: 'grid-item grid-item--width2 grid-item--height2',
|
26
|
+
} ),
|
21
27
|
el( 'div', { className: 'grid-item grid-item--width2' } ),
|
22
28
|
el( 'div', { className: 'grid-item' } ),
|
23
29
|
el( 'div', { className: 'grid-item grid-item--height2' } ),
|
@@ -12,5 +12,9 @@
|
|
12
12
|
"textdomain": "iframed-multiple-stylesheets",
|
13
13
|
"editorScript": "iframed-multiple-stylesheets-editor-script",
|
14
14
|
"editorStyle": "file:./editor.css",
|
15
|
-
"style": [
|
15
|
+
"style": [
|
16
|
+
"iframed-multiple-stylesheets-style",
|
17
|
+
"iframed-multiple-stylesheets-style2",
|
18
|
+
"file:./style3.css"
|
19
|
+
]
|
16
20
|
}
|
@@ -10,7 +10,11 @@
|
|
10
10
|
|
11
11
|
const allowedBlocksWhenSingleEmptyChild = [ 'core/image', 'core/list' ];
|
12
12
|
const allowedBlocksWhenTwoChildren = [ 'core/gallery', 'core/video' ];
|
13
|
-
const allowedBlocksWhenTreeOrMoreChildren = [
|
13
|
+
const allowedBlocksWhenTreeOrMoreChildren = [
|
14
|
+
'core/gallery',
|
15
|
+
'core/video',
|
16
|
+
'core/list',
|
17
|
+
];
|
14
18
|
|
15
19
|
registerBlockType( 'test/allowed-blocks-dynamic', {
|
16
20
|
apiVersion: 3,
|
@@ -26,15 +30,15 @@
|
|
26
30
|
},
|
27
31
|
[ props.clientId ]
|
28
32
|
);
|
29
|
-
const blockProps = useBlockProps({
|
33
|
+
const blockProps = useBlockProps( {
|
30
34
|
...divProps,
|
31
35
|
'data-number-of-children': numberOfChildren,
|
32
|
-
});
|
36
|
+
} );
|
33
37
|
|
34
38
|
let allowedBlocks = allowedBlocksWhenSingleEmptyChild;
|
35
39
|
if ( numberOfChildren === 2 ) {
|
36
40
|
allowedBlocks = allowedBlocksWhenTwoChildren;
|
37
|
-
} else if( numberOfChildren > 2 ){
|
41
|
+
} else if ( numberOfChildren > 2 ) {
|
38
42
|
allowedBlocks = allowedBlocksWhenTreeOrMoreChildren;
|
39
43
|
}
|
40
44
|
|
@@ -42,12 +46,12 @@
|
|
42
46
|
'div',
|
43
47
|
blockProps,
|
44
48
|
el( InnerBlocks, {
|
45
|
-
allowedBlocks
|
49
|
+
allowedBlocks,
|
46
50
|
} )
|
47
51
|
);
|
48
52
|
},
|
49
53
|
save() {
|
50
54
|
return el( 'div', divProps, el( InnerBlocks.Content ) );
|
51
|
-
}
|
55
|
+
},
|
52
56
|
} );
|
53
57
|
} )();
|
@@ -3,16 +3,14 @@
|
|
3
3
|
const { createElement: el } = wp.element;
|
4
4
|
const { InnerBlocks } = wp.blockEditor;
|
5
5
|
|
6
|
-
|
6
|
+
const divProps = {
|
7
7
|
className: 'product',
|
8
8
|
style: { outline: '1px solid gray', padding: 5 },
|
9
9
|
};
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
const template = [
|
14
|
-
[ 'core/image' ],
|
15
|
-
];
|
11
|
+
// without a placeholder within the inner blocks it can be difficult to select the block using e2e tests
|
12
|
+
// especially using Puppeteer, so we use an image block which has a placeholder.
|
13
|
+
const template = [ [ 'core/image' ] ];
|
16
14
|
|
17
15
|
const save = function () {
|
18
16
|
return el( 'div', divProps, el( InnerBlocks.Content ) );
|
@@ -38,11 +36,11 @@
|
|
38
36
|
'div',
|
39
37
|
divProps,
|
40
38
|
el( InnerBlocks, {
|
41
|
-
|
39
|
+
template,
|
42
40
|
prioritizedInserterBlocks: [
|
43
|
-
|
41
|
+
'core/audio',
|
44
42
|
'core/spacer',
|
45
|
-
|
43
|
+
'core/code',
|
46
44
|
],
|
47
45
|
} )
|
48
46
|
);
|
@@ -51,32 +49,34 @@
|
|
51
49
|
save,
|
52
50
|
} );
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
} );
|
52
|
+
registerBlockType(
|
53
|
+
'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks',
|
54
|
+
{
|
55
|
+
title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
|
56
|
+
icon: 'carrot',
|
57
|
+
category: 'text',
|
58
|
+
edit() {
|
59
|
+
return el(
|
60
|
+
'div',
|
61
|
+
divProps,
|
62
|
+
el( InnerBlocks, {
|
63
|
+
template,
|
64
|
+
allowedBlocks: [
|
65
|
+
'core/spacer',
|
66
|
+
'core/code',
|
67
|
+
'core/paragraph',
|
68
|
+
'core/heading',
|
69
|
+
],
|
70
|
+
prioritizedInserterBlocks: [
|
71
|
+
'core/audio', // this is **not** in the allowedBlocks list
|
72
|
+
'core/spacer',
|
73
|
+
'core/code',
|
74
|
+
],
|
75
|
+
} )
|
76
|
+
);
|
77
|
+
},
|
81
78
|
|
79
|
+
save,
|
80
|
+
}
|
81
|
+
);
|
82
82
|
} )();
|
@@ -53,9 +53,13 @@
|
|
53
53
|
category: 'text',
|
54
54
|
|
55
55
|
edit: function InnerBlocksNoLockingEdit() {
|
56
|
-
return el(
|
57
|
-
|
58
|
-
|
56
|
+
return el(
|
57
|
+
'div',
|
58
|
+
useBlockProps(),
|
59
|
+
el( InnerBlocks, {
|
60
|
+
template: TEMPLATE,
|
61
|
+
} )
|
62
|
+
);
|
59
63
|
},
|
60
64
|
|
61
65
|
save,
|
@@ -68,10 +72,14 @@
|
|
68
72
|
category: 'text',
|
69
73
|
|
70
74
|
edit: function InnerBlocksBlocksLockingAllEdit() {
|
71
|
-
return el(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
return el(
|
76
|
+
'div',
|
77
|
+
useBlockProps(),
|
78
|
+
el( InnerBlocks, {
|
79
|
+
template: TEMPLATE,
|
80
|
+
templateLock: 'all',
|
81
|
+
} )
|
82
|
+
);
|
75
83
|
},
|
76
84
|
|
77
85
|
save,
|
@@ -92,7 +100,9 @@
|
|
92
100
|
|
93
101
|
edit: function InnerBlocksUpdateLockedTemplateEdit( props ) {
|
94
102
|
const hasUpdatedTemplated = props.attributes.hasUpdatedTemplate;
|
95
|
-
return el(
|
103
|
+
return el(
|
104
|
+
'div',
|
105
|
+
null,
|
96
106
|
el(
|
97
107
|
'button',
|
98
108
|
{
|
@@ -102,12 +112,16 @@
|
|
102
112
|
},
|
103
113
|
'Update template'
|
104
114
|
),
|
105
|
-
el(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
el(
|
116
|
+
'div',
|
117
|
+
useBlockProps(),
|
118
|
+
el( InnerBlocks, {
|
119
|
+
template: hasUpdatedTemplated
|
120
|
+
? TEMPLATE_TWO_PARAGRAPHS
|
121
|
+
: TEMPLATE,
|
122
|
+
templateLock: 'all',
|
123
|
+
} )
|
124
|
+
)
|
111
125
|
);
|
112
126
|
},
|
113
127
|
|
@@ -121,10 +135,14 @@
|
|
121
135
|
category: 'text',
|
122
136
|
|
123
137
|
edit: function InnerBlocksParagraphPlaceholderEdit() {
|
124
|
-
return el(
|
125
|
-
|
126
|
-
|
127
|
-
|
138
|
+
return el(
|
139
|
+
'div',
|
140
|
+
useBlockProps(),
|
141
|
+
el( InnerBlocks, {
|
142
|
+
template: TEMPLATE_PARAGRAPH_PLACEHOLDER,
|
143
|
+
templateInsertUpdatesSelection: true,
|
144
|
+
} )
|
145
|
+
);
|
128
146
|
},
|
129
147
|
|
130
148
|
save,
|
@@ -171,36 +189,41 @@
|
|
171
189
|
},
|
172
190
|
|
173
191
|
edit: function InnerBlocksTransformerTargetEdit() {
|
174
|
-
return el(
|
175
|
-
|
176
|
-
|
192
|
+
return el(
|
193
|
+
'div',
|
194
|
+
useBlockProps(),
|
195
|
+
el( InnerBlocks, {
|
196
|
+
template: TEMPLATE,
|
197
|
+
} )
|
198
|
+
);
|
177
199
|
},
|
178
200
|
|
179
201
|
save,
|
180
202
|
} );
|
181
203
|
|
182
|
-
registerBlockType(
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
icon: 'cart',
|
188
|
-
category: 'text',
|
204
|
+
registerBlockType( 'test/test-inner-blocks-async-template', {
|
205
|
+
apiVersion: 3,
|
206
|
+
title: 'Test Inner Blocks Async Template',
|
207
|
+
icon: 'cart',
|
208
|
+
category: 'text',
|
189
209
|
|
190
|
-
|
191
|
-
|
210
|
+
edit: function InnerBlocksAsyncTemplateEdit() {
|
211
|
+
const [ template, setTemplate ] = useState( [] );
|
192
212
|
|
193
|
-
|
194
|
-
|
195
|
-
|
213
|
+
setInterval( () => {
|
214
|
+
setTemplate( TEMPLATE_TWO_PARAGRAPHS );
|
215
|
+
}, 1000 );
|
196
216
|
|
197
|
-
|
217
|
+
return el(
|
218
|
+
'div',
|
219
|
+
useBlockProps(),
|
220
|
+
el( InnerBlocks, {
|
198
221
|
template,
|
199
|
-
} )
|
200
|
-
|
222
|
+
} )
|
223
|
+
);
|
224
|
+
},
|
201
225
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
);
|
226
|
+
// Purposely do not save inner blocks so that it's possible to test template resolution.
|
227
|
+
save() {},
|
228
|
+
} );
|
206
229
|
} )();
|
@@ -21,7 +21,7 @@ store( 'directive-context', {
|
|
21
21
|
get isProxyPreservedOnCopy() {
|
22
22
|
const { obj, obj2 } = getContext();
|
23
23
|
return obj === obj2;
|
24
|
-
}
|
24
|
+
},
|
25
25
|
},
|
26
26
|
actions: {
|
27
27
|
updateContext( event ) {
|
@@ -47,7 +47,7 @@ store( 'directive-context', {
|
|
47
47
|
copyObj() {
|
48
48
|
const ctx = getContext();
|
49
49
|
ctx.obj2 = ctx.obj;
|
50
|
-
}
|
50
|
+
},
|
51
51
|
},
|
52
52
|
} );
|
53
53
|
|
@@ -92,7 +92,6 @@ const { actions } = store( 'directive-context-navigate', {
|
|
92
92
|
return routerActions.navigate( url, { force: true, html } );
|
93
93
|
}
|
94
94
|
);
|
95
|
-
|
96
95
|
},
|
97
96
|
*asyncNavigate() {
|
98
97
|
yield actions.navigate();
|
@@ -118,4 +117,4 @@ store( 'directive-context-watch', {
|
|
118
117
|
ctx.changes = ctx.changes + 1;
|
119
118
|
},
|
120
119
|
},
|
121
|
-
});
|
120
|
+
} );
|
@@ -1,7 +1,12 @@
|
|
1
1
|
/**
|
2
2
|
* WordPress dependencies
|
3
3
|
*/
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
store,
|
6
|
+
getContext,
|
7
|
+
useInit,
|
8
|
+
privateApis,
|
9
|
+
} from '@wordpress/interactivity';
|
5
10
|
|
6
11
|
const { state } = store( 'directive-each' );
|
7
12
|
|
@@ -16,8 +21,8 @@ store( 'directive-each', {
|
|
16
21
|
fruits: [ 'avocado', 'banana', 'cherimoya' ],
|
17
22
|
get fruitId() {
|
18
23
|
const { idPrefix, fruit } = getContext();
|
19
|
-
return `${idPrefix}${fruit}`;
|
20
|
-
}
|
24
|
+
return `${ idPrefix }${ fruit }`;
|
25
|
+
},
|
21
26
|
},
|
22
27
|
actions: {
|
23
28
|
removeFruit() {
|
@@ -43,17 +48,17 @@ store( 'directive-each', {
|
|
43
48
|
{
|
44
49
|
title: 'A Game of Thrones',
|
45
50
|
author: 'George R.R. Martin',
|
46
|
-
isbn:
|
51
|
+
isbn: '9780553588484',
|
47
52
|
},
|
48
53
|
{
|
49
54
|
title: 'A Clash of Kings',
|
50
55
|
author: 'George R.R. Martin',
|
51
|
-
isbn:
|
56
|
+
isbn: '9780553381696',
|
52
57
|
},
|
53
58
|
{
|
54
59
|
title: 'A Storm of Swords',
|
55
60
|
author: 'George R.R. Martin',
|
56
|
-
isbn:
|
61
|
+
isbn: '9780553573428',
|
57
62
|
},
|
58
63
|
],
|
59
64
|
},
|
@@ -70,7 +75,7 @@ store( 'directive-each', {
|
|
70
75
|
const book = {
|
71
76
|
title: 'A Feast for Crows',
|
72
77
|
author: 'George R.R. Martin',
|
73
|
-
isbn:
|
78
|
+
isbn: '9780553582024',
|
74
79
|
};
|
75
80
|
state.books.splice( 0, 0, book );
|
76
81
|
},
|
@@ -78,7 +83,7 @@ store( 'directive-each', {
|
|
78
83
|
const book = {
|
79
84
|
title: 'A Feast for Crows',
|
80
85
|
author: 'George R.R. Martin',
|
81
|
-
isbn:
|
86
|
+
isbn: '9780553582024',
|
82
87
|
};
|
83
88
|
state.books.splice( 0, 1, book );
|
84
89
|
},
|
@@ -101,58 +106,63 @@ store( 'directive-each', {
|
|
101
106
|
if ( state.numbers.length > 0 ) {
|
102
107
|
state.numbers.unshift( state.numbers[ 0 ] - 1 );
|
103
108
|
}
|
104
|
-
}
|
109
|
+
},
|
105
110
|
},
|
106
111
|
} );
|
107
112
|
|
108
113
|
store( 'directive-each', {
|
109
114
|
state: {
|
110
|
-
emptyList: []
|
115
|
+
emptyList: [],
|
111
116
|
},
|
112
117
|
actions: {
|
113
118
|
addItem() {
|
114
119
|
state.emptyList.push( `item ${ state.emptyList.length }` );
|
115
|
-
}
|
120
|
+
},
|
116
121
|
},
|
117
122
|
} );
|
118
123
|
|
119
124
|
store( 'directive-each', {
|
120
125
|
state: {
|
121
126
|
numbersAndNames: [
|
122
|
-
{ name:
|
123
|
-
{ name:
|
127
|
+
{ name: 'two', value: 2 },
|
128
|
+
{ name: 'three', value: 3 },
|
124
129
|
],
|
125
130
|
},
|
126
131
|
actions: {
|
127
132
|
unshiftNumberAndName() {
|
128
|
-
state.numbersAndNames.unshift( { name:
|
129
|
-
}
|
133
|
+
state.numbersAndNames.unshift( { name: 'one', value: 1 } );
|
134
|
+
},
|
130
135
|
},
|
131
136
|
} );
|
132
137
|
|
133
138
|
store( 'directive-each', {
|
134
139
|
state: {
|
135
140
|
animalBreeds: [
|
136
|
-
{ name:
|
137
|
-
{ name:
|
141
|
+
{ name: 'Dog', breeds: [ 'chihuahua', 'rottweiler' ] },
|
142
|
+
{ name: 'Cat', breeds: [ 'sphynx', 'siamese' ] },
|
138
143
|
],
|
139
144
|
},
|
140
145
|
actions: {
|
141
146
|
addAnimal() {
|
142
147
|
state.animalBreeds.unshift( {
|
143
|
-
name:
|
148
|
+
name: 'Rat',
|
149
|
+
breeds: [ 'dumbo', 'rex' ],
|
144
150
|
} );
|
145
151
|
},
|
146
152
|
addBreeds() {
|
147
|
-
state
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
153
|
+
state.animalBreeds.forEach( ( { name, breeds } ) => {
|
154
|
+
if ( name === 'Dog' ) {
|
155
|
+
breeds.unshift( 'german shepherd' );
|
156
|
+
}
|
157
|
+
if ( name === 'Cat' ) {
|
158
|
+
breeds.unshift( 'maine coon' );
|
159
|
+
}
|
160
|
+
if ( name === 'Rat' ) {
|
161
|
+
breeds.unshift( 'satin' );
|
162
|
+
}
|
163
|
+
} );
|
164
|
+
},
|
165
|
+
},
|
156
166
|
} );
|
157
167
|
|
158
168
|
const html = `
|
@@ -180,14 +190,14 @@ store( 'directive-each', {
|
|
180
190
|
actions: {
|
181
191
|
*navigate() {
|
182
192
|
const { actions } = yield import(
|
183
|
-
|
193
|
+
'@wordpress/interactivity-router'
|
184
194
|
);
|
185
195
|
return actions.navigate( window.location, {
|
186
196
|
force: true,
|
187
197
|
html,
|
188
198
|
} );
|
189
199
|
},
|
190
|
-
}
|
200
|
+
},
|
191
201
|
} );
|
192
202
|
|
193
203
|
const { directive } = privateApis(
|
@@ -208,12 +218,11 @@ directive(
|
|
208
218
|
{ priority: 2 }
|
209
219
|
);
|
210
220
|
|
211
|
-
store('directive-each', {
|
212
|
-
|
221
|
+
store( 'directive-each', {
|
222
|
+
callbacks: {
|
213
223
|
updateCallbackRunCount() {
|
214
224
|
const ctx = getContext();
|
215
225
|
ctx.callbackRunCount += 1;
|
216
|
-
}
|
217
|
-
|
218
|
-
});
|
219
|
-
|
226
|
+
},
|
227
|
+
},
|
228
|
+
} );
|
@@ -34,7 +34,7 @@ const { state } = store( 'directive-on-window', {
|
|
34
34
|
},
|
35
35
|
init() {
|
36
36
|
state.isEventAttached = 'yes';
|
37
|
-
}
|
37
|
+
},
|
38
38
|
},
|
39
39
|
actions: {
|
40
40
|
visibilityHandler: () => {
|
@@ -46,6 +46,6 @@ const { state } = store( 'directive-on-window', {
|
|
46
46
|
},
|
47
47
|
resizeSecondHandler: () => {
|
48
48
|
state.resizeSecondHandler = 'yes';
|
49
|
-
}
|
50
|
-
}
|
49
|
+
},
|
50
|
+
},
|
51
51
|
} );
|
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
store,
|
6
6
|
getContext,
|
7
7
|
useEffect,
|
8
|
-
privateApis
|
8
|
+
privateApis,
|
9
9
|
} from '@wordpress/interactivity';
|
10
10
|
|
11
11
|
const { directive, deepSignal, h } = privateApis(
|
@@ -24,8 +24,11 @@ const namespace = 'directive-priorities';
|
|
24
24
|
*/
|
25
25
|
const executionProof = ( n ) => {
|
26
26
|
const el = document.querySelector( '[data-testid="execution order"]' );
|
27
|
-
if ( ! el.textContent ) {
|
28
|
-
|
27
|
+
if ( ! el.textContent ) {
|
28
|
+
el.textContent = n;
|
29
|
+
} else {
|
30
|
+
el.textContent += `, ${ n }`;
|
31
|
+
}
|
29
32
|
};
|
30
33
|
|
31
34
|
/**
|
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
useInit,
|
7
7
|
useWatch,
|
8
8
|
getElement,
|
9
|
-
privateApis
|
9
|
+
privateApis,
|
10
10
|
} from '@wordpress/interactivity';
|
11
11
|
|
12
12
|
const { directive, cloneElement } = privateApis(
|
@@ -16,7 +16,11 @@ const { directive, cloneElement } = privateApis(
|
|
16
16
|
// Custom directive to show hide the content elements in which it is placed.
|
17
17
|
directive(
|
18
18
|
'show-children',
|
19
|
-
( {
|
19
|
+
( {
|
20
|
+
directives: { 'show-children': showChildren },
|
21
|
+
element,
|
22
|
+
evaluate,
|
23
|
+
} ) => {
|
20
24
|
const entry = showChildren.find(
|
21
25
|
( { suffix } ) => suffix === 'default'
|
22
26
|
);
|
@@ -51,7 +55,7 @@ const { state } = store( 'directive-run', {
|
|
51
55
|
isHydrated: 'no',
|
52
56
|
isMounted: 'no',
|
53
57
|
renderCount: 0,
|
54
|
-
clickCount: 0
|
58
|
+
clickCount: 0,
|
55
59
|
},
|
56
60
|
actions: {
|
57
61
|
toggle() {
|
@@ -62,7 +66,7 @@ const { state } = store( 'directive-run', {
|
|
62
66
|
},
|
63
67
|
*navigate() {
|
64
68
|
const { actions } = yield import(
|
65
|
-
|
69
|
+
'@wordpress/interactivity-router'
|
66
70
|
);
|
67
71
|
return actions.navigate( window.location, {
|
68
72
|
force: true,
|
@@ -84,13 +88,13 @@ const { state } = store( 'directive-run', {
|
|
84
88
|
// Runs only on first render.
|
85
89
|
useInit( () => {
|
86
90
|
const { ref } = getElement();
|
87
|
-
ref
|
88
|
-
|
89
|
-
|
91
|
+
ref.closest(
|
92
|
+
'[data-testid="wp-run hooks results"]'
|
93
|
+
).setAttribute( 'data-init', 'initialized' );
|
90
94
|
return () => {
|
91
|
-
ref
|
92
|
-
|
93
|
-
|
95
|
+
ref.closest(
|
96
|
+
'[data-testid="wp-run hooks results"]'
|
97
|
+
).setAttribute( 'data-init', 'cleaned up' );
|
94
98
|
};
|
95
99
|
} );
|
96
100
|
|
@@ -99,15 +103,15 @@ const { state } = store( 'directive-run', {
|
|
99
103
|
useWatch( () => {
|
100
104
|
const { ref } = getElement();
|
101
105
|
const { clickCount } = state;
|
102
|
-
ref
|
103
|
-
|
104
|
-
|
106
|
+
ref.closest(
|
107
|
+
'[data-testid="wp-run hooks results"]'
|
108
|
+
).setAttribute( 'data-watch', clickCount );
|
105
109
|
return () => {
|
106
|
-
ref
|
107
|
-
|
108
|
-
|
110
|
+
ref.closest(
|
111
|
+
'[data-testid="wp-run hooks results"]'
|
112
|
+
).setAttribute( 'data-watch', 'cleaned up' );
|
109
113
|
};
|
110
114
|
} );
|
111
|
-
}
|
112
|
-
}
|
115
|
+
},
|
116
|
+
},
|
113
117
|
} );
|
@@ -7,13 +7,12 @@ const { h } = privateApis(
|
|
7
7
|
'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'
|
8
8
|
);
|
9
9
|
|
10
|
-
|
11
10
|
const { state } = store( 'directive-context', {
|
12
11
|
state: {
|
13
12
|
text: 'Text 1',
|
14
|
-
component: () =>
|
13
|
+
component: () => h( 'div', {}, state.text ),
|
15
14
|
number: 1,
|
16
|
-
boolean: true
|
15
|
+
boolean: true,
|
17
16
|
},
|
18
17
|
actions: {
|
19
18
|
toggleStateText() {
|
@@ -13,7 +13,9 @@ directive(
|
|
13
13
|
'show-mock',
|
14
14
|
( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
|
15
15
|
const entry = showMock.find( ( { suffix } ) => suffix === 'default' );
|
16
|
-
if ( ! evaluate( entry ) ) {
|
16
|
+
if ( ! evaluate( entry ) ) {
|
17
|
+
return null;
|
18
|
+
}
|
17
19
|
return element;
|
18
20
|
}
|
19
21
|
);
|
@@ -14,8 +14,8 @@ const { state } = store( 'router', {
|
|
14
14
|
data: {
|
15
15
|
get getterProp() {
|
16
16
|
return `value from getter (${ state.data.prop1 })`;
|
17
|
-
}
|
18
|
-
}
|
17
|
+
},
|
18
|
+
},
|
19
19
|
},
|
20
20
|
actions: {
|
21
21
|
*navigate( e ) {
|
@@ -29,7 +29,7 @@ const { state } = store( 'router', {
|
|
29
29
|
const { timeout } = state;
|
30
30
|
|
31
31
|
const { actions } = yield import(
|
32
|
-
|
32
|
+
'@wordpress/interactivity-router'
|
33
33
|
);
|
34
34
|
yield actions.navigate( e.target.href, { force, timeout } );
|
35
35
|
|
@@ -10,6 +10,4 @@ const cdata = `
|
|
10
10
|
const cdataElement = new DOMParser()
|
11
11
|
.parseFromString( cdata, 'text/xml' )
|
12
12
|
.querySelector( 'div' );
|
13
|
-
document
|
14
|
-
.getElementById( 'replace-with-cdata' )
|
15
|
-
.replaceWith( cdataElement );
|
13
|
+
document.getElementById( 'replace-with-cdata' ).replaceWith( cdataElement );
|
@@ -6,15 +6,19 @@ import { store, getContext, withScope } from '@wordpress/interactivity';
|
|
6
6
|
store( 'with-scope', {
|
7
7
|
callbacks: {
|
8
8
|
asyncInit: () => {
|
9
|
-
setTimeout(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
setTimeout(
|
10
|
+
withScope( function* () {
|
11
|
+
yield new Promise( ( resolve ) =>
|
12
|
+
setTimeout( resolve, 1 )
|
13
|
+
);
|
14
|
+
const context = getContext();
|
15
|
+
context.asyncCounter += 1;
|
16
|
+
}, 1 )
|
17
|
+
);
|
14
18
|
},
|
15
19
|
syncInit: () => {
|
16
|
-
const context = getContext()
|
20
|
+
const context = getContext();
|
17
21
|
context.syncCounter += 1;
|
18
|
-
}
|
22
|
+
},
|
19
23
|
},
|
20
24
|
} );
|
@@ -48,15 +48,16 @@
|
|
48
48
|
el(
|
49
49
|
Button,
|
50
50
|
{
|
51
|
-
variant:
|
51
|
+
variant: 'primary',
|
52
52
|
onClick: () => {
|
53
53
|
dispatch(
|
54
54
|
'core/annotations'
|
55
55
|
).__experimentalAddAnnotation( {
|
56
56
|
source: 'e2e-tests',
|
57
|
-
blockClientId:
|
58
|
-
|
59
|
-
|
57
|
+
blockClientId:
|
58
|
+
select(
|
59
|
+
'core/block-editor'
|
60
|
+
).getBlockOrder()[ 0 ],
|
60
61
|
richTextIdentifier: 'content',
|
61
62
|
range: {
|
62
63
|
start: parseInt( this.state.start, 10 ),
|
@@ -70,7 +71,7 @@
|
|
70
71
|
el(
|
71
72
|
Button,
|
72
73
|
{
|
73
|
-
variant:
|
74
|
+
variant: 'primary',
|
74
75
|
onClick: () => {
|
75
76
|
dispatch(
|
76
77
|
'core/annotations'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
(function () {
|
1
|
+
( function () {
|
2
2
|
const fruits = {
|
3
3
|
name: 'fruit',
|
4
4
|
// The prefix that triggers this completer
|
@@ -20,9 +20,7 @@
|
|
20
20
|
// Declares that the Grapes option is disabled
|
21
21
|
isOptionDisabled: ( option ) => option.name === 'Grapes',
|
22
22
|
// Declares completions should be inserted as abbreviations
|
23
|
-
getOptionCompletion: ( option ) =>
|
24
|
-
option.visual
|
25
|
-
),
|
23
|
+
getOptionCompletion: ( option ) => option.visual,
|
26
24
|
};
|
27
25
|
|
28
26
|
function duplicateUserMentions( completers ) {
|
@@ -43,7 +41,7 @@
|
|
43
41
|
? [ ...completers, fruits, copiedUsers ]
|
44
42
|
: completers;
|
45
43
|
}
|
46
|
-
|
44
|
+
|
47
45
|
// Adding the filter with a priority of 11
|
48
46
|
// to ensure it fires after the default user mentions are added.
|
49
47
|
wp.hooks.addFilter(
|
@@ -52,4 +50,4 @@
|
|
52
50
|
appendTestCompleters,
|
53
51
|
11
|
54
52
|
);
|
55
|
-
})()
|
53
|
+
} )();
|