@wordpress/e2e-tests 9.3.1-next.v.0 → 9.4.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 9.4.0 (2026-01-29)
6
+
5
7
  ## 9.3.0 (2026-01-16)
6
8
 
7
9
  ## 9.1.0 (2025-11-26)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-tests",
3
- "version": "9.3.1-next.v.0+b8934fcf9",
3
+ "version": "9.4.0",
4
4
  "description": "Test plugins and mu-plugins for E2E tests in WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -24,8 +24,8 @@
24
24
  "npm": ">=8.19.2"
25
25
  },
26
26
  "dependencies": {
27
- "@wordpress/interactivity": "^6.38.1-next.v.0+b8934fcf9",
28
- "@wordpress/interactivity-router": "^2.38.2-next.v.0+b8934fcf9"
27
+ "@wordpress/interactivity": "^6.39.0",
28
+ "@wordpress/interactivity-router": "^2.39.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "jest": ">=29",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "17529010285784fd2e735348a28391c79de87c88"
39
+ "gitHead": "eee1cfb1472f11183e40fb77465a5f13145df7ad"
40
40
  }
@@ -1,23 +1,22 @@
1
1
  ( function () {
2
2
  const registerBlockType = wp.blocks.registerBlockType;
3
3
  const el = wp.element.createElement;
4
+ const { useBlockProps } = wp.blockEditor;
4
5
 
5
6
  const baseBlock = {
6
7
  icon: 'cart',
7
8
  category: 'text',
8
- edit() {
9
- return el(
10
- 'div',
11
- { style: { outline: '1px solid gray', padding: 5 } },
12
- 'Test Align Hook'
13
- );
9
+ edit: function Edit() {
10
+ const blockProps = useBlockProps( {
11
+ style: { outline: '1px solid gray', padding: 5 },
12
+ } );
13
+ return el( 'div', blockProps, 'Test Align Hook' );
14
14
  },
15
15
  save() {
16
- return el(
17
- 'div',
18
- { style: { outline: '1px solid gray', padding: 5 } },
19
- 'Test Align Hook'
20
- );
16
+ const blockProps = useBlockProps.save( {
17
+ style: { outline: '1px solid gray', padding: 5 },
18
+ } );
19
+ return el( 'div', blockProps, 'Test Align Hook' );
21
20
  },
22
21
  };
23
22
 
@@ -25,6 +24,7 @@
25
24
  'test/test-no-alignment-set',
26
25
  Object.assign(
27
26
  {
27
+ apiVersion: 3,
28
28
  title: 'Test No Alignment Set',
29
29
  },
30
30
  baseBlock
@@ -35,6 +35,7 @@
35
35
  'test/test-align-true',
36
36
  Object.assign(
37
37
  {
38
+ apiVersion: 3,
38
39
  title: 'Test Align True',
39
40
  supports: {
40
41
  align: true,
@@ -48,6 +49,7 @@
48
49
  'test/test-align-array',
49
50
  Object.assign(
50
51
  {
52
+ apiVersion: 3,
51
53
  title: 'Test Align Array',
52
54
  supports: {
53
55
  align: [ 'left', 'center' ],
@@ -61,6 +63,7 @@
61
63
  'test/test-default-align',
62
64
  Object.assign(
63
65
  {
66
+ apiVersion: 3,
64
67
  title: 'Test Default Align',
65
68
  attributes: {
66
69
  align: {
@@ -1,9 +1,10 @@
1
1
  ( function () {
2
- const { createElement: el, Fragment } = wp.element;
2
+ const { createElement: el } = wp.element;
3
3
  const { registerBlockType } = wp.blocks;
4
- const { InnerBlocks } = wp.blockEditor;
4
+ const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
5
5
 
6
6
  registerBlockType( 'gutenberg/test-context-provider', {
7
+ apiVersion: 3,
7
8
  title: 'Test Context Provider',
8
9
 
9
10
  icon: 'list-view',
@@ -17,10 +18,16 @@
17
18
 
18
19
  category: 'text',
19
20
 
20
- edit( { attributes, setAttributes } ) {
21
+ edit: function Edit( { attributes, setAttributes } ) {
22
+ const blockProps = useBlockProps();
23
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
24
+ template: [ [ 'gutenberg/test-context-consumer', {} ] ],
25
+ templateLock: 'all',
26
+ templateInsertUpdatesSelection: true,
27
+ } );
21
28
  return el(
22
- Fragment,
23
- null,
29
+ 'div',
30
+ innerBlocksProps,
24
31
  el( 'input', {
25
32
  value: attributes.recordId,
26
33
  onChange( event ) {
@@ -29,11 +36,7 @@
29
36
  } );
30
37
  },
31
38
  } ),
32
- el( InnerBlocks, {
33
- template: [ [ 'gutenberg/test-context-consumer', {} ] ],
34
- templateLock: 'all',
35
- templateInsertUpdatesSelection: true,
36
- } )
39
+ innerBlocksProps.children
37
40
  );
38
41
  },
39
42
 
@@ -43,6 +46,7 @@
43
46
  } );
44
47
 
45
48
  registerBlockType( 'gutenberg/test-context-consumer', {
49
+ apiVersion: 3,
46
50
  title: 'Test Context Consumer',
47
51
 
48
52
  icon: 'list-view',
@@ -54,8 +58,13 @@
54
58
 
55
59
  category: 'text',
56
60
 
57
- edit( { context } ) {
58
- return 'The record ID is: ' + context[ 'gutenberg/recordId' ];
61
+ edit: function Edit( { context } ) {
62
+ const blockProps = useBlockProps();
63
+ return el(
64
+ 'div',
65
+ blockProps,
66
+ 'The record ID is: ' + context[ 'gutenberg/recordId' ]
67
+ );
59
68
  },
60
69
 
61
70
  save() {
@@ -1,7 +1,7 @@
1
1
  ( function () {
2
2
  const registerBlockType = wp.blocks.registerBlockType;
3
3
  const el = wp.element.createElement;
4
- const InnerBlocks = wp.blockEditor.InnerBlocks;
4
+ const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
5
5
  const circle = el( 'circle', {
6
6
  cx: 10,
7
7
  cy: 10,
@@ -17,29 +17,28 @@
17
17
  );
18
18
 
19
19
  registerBlockType( 'test/test-single-svg-icon', {
20
+ apiVersion: 3,
20
21
  title: 'TestSimpleSvgIcon',
21
22
  icon: svg,
22
23
  category: 'text',
23
24
 
24
- edit() {
25
- return el(
26
- 'div',
27
- {
28
- className: 'test-single-svg-icon',
29
- style: { outline: '1px solid gray', padding: 5 },
30
- },
31
- el( InnerBlocks, {
32
- allowedBlocks: [ 'core/paragraph', 'core/image' ],
33
- template: [
34
- [
35
- 'core/paragraph',
36
- {
37
- content: 'TestSimpleSvgIcon',
38
- },
39
- ],
25
+ edit: function Edit() {
26
+ const blockProps = useBlockProps( {
27
+ className: 'test-single-svg-icon',
28
+ style: { outline: '1px solid gray', padding: 5 },
29
+ } );
30
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
31
+ allowedBlocks: [ 'core/paragraph', 'core/image' ],
32
+ template: [
33
+ [
34
+ 'core/paragraph',
35
+ {
36
+ content: 'TestSimpleSvgIcon',
37
+ },
40
38
  ],
41
- } )
42
- );
39
+ ],
40
+ } );
41
+ return el( 'div', innerBlocksProps );
43
42
  },
44
43
 
45
44
  save() {
@@ -55,29 +54,28 @@
55
54
  } );
56
55
 
57
56
  registerBlockType( 'test/test-dash-icon', {
57
+ apiVersion: 3,
58
58
  title: 'TestSimpleDashIcon',
59
59
  icon: 'cart',
60
60
  category: 'text',
61
61
 
62
- edit() {
63
- return el(
64
- 'div',
65
- {
66
- className: 'test-dash-icon',
67
- style: { outline: '1px solid gray', padding: 5 },
68
- },
69
- el( InnerBlocks, {
70
- allowedBlocks: [ 'core/paragraph', 'core/image' ],
71
- template: [
72
- [
73
- 'core/paragraph',
74
- {
75
- content: 'TestDashIcon',
76
- },
77
- ],
62
+ edit: function Edit() {
63
+ const blockProps = useBlockProps( {
64
+ className: 'test-dash-icon',
65
+ style: { outline: '1px solid gray', padding: 5 },
66
+ } );
67
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
68
+ allowedBlocks: [ 'core/paragraph', 'core/image' ],
69
+ template: [
70
+ [
71
+ 'core/paragraph',
72
+ {
73
+ content: 'TestDashIcon',
74
+ },
78
75
  ],
79
- } )
80
- );
76
+ ],
77
+ } );
78
+ return el( 'div', innerBlocksProps );
81
79
  },
82
80
 
83
81
  save() {
@@ -93,31 +91,30 @@
93
91
  } );
94
92
 
95
93
  registerBlockType( 'test/test-function-icon', {
94
+ apiVersion: 3,
96
95
  title: 'TestFunctionIcon',
97
96
  icon() {
98
97
  return svg;
99
98
  },
100
99
  category: 'text',
101
100
 
102
- edit() {
103
- return el(
104
- 'div',
105
- {
106
- className: 'test-function-icon',
107
- style: { outline: '1px solid gray', padding: 5 },
108
- },
109
- el( InnerBlocks, {
110
- allowedBlocks: [ 'core/paragraph', 'core/image' ],
111
- template: [
112
- [
113
- 'core/paragraph',
114
- {
115
- content: 'TestFunctionIcon',
116
- },
117
- ],
101
+ edit: function Edit() {
102
+ const blockProps = useBlockProps( {
103
+ className: 'test-function-icon',
104
+ style: { outline: '1px solid gray', padding: 5 },
105
+ } );
106
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
107
+ allowedBlocks: [ 'core/paragraph', 'core/image' ],
108
+ template: [
109
+ [
110
+ 'core/paragraph',
111
+ {
112
+ content: 'TestFunctionIcon',
113
+ },
118
114
  ],
119
- } )
120
- );
115
+ ],
116
+ } );
117
+ return el( 'div', innerBlocksProps );
121
118
  },
122
119
 
123
120
  save() {
@@ -133,6 +130,7 @@
133
130
  } );
134
131
 
135
132
  registerBlockType( 'test/test-dash-icon-colors', {
133
+ apiVersion: 3,
136
134
  title: 'TestDashIconColors',
137
135
  icon: {
138
136
  background: '#010000',
@@ -141,25 +139,23 @@
141
139
  },
142
140
  category: 'text',
143
141
 
144
- edit() {
145
- return el(
146
- 'div',
147
- {
148
- className: 'test-dash-icon-colors',
149
- style: { outline: '1px solid gray', padding: 5 },
150
- },
151
- el( InnerBlocks, {
152
- allowedBlocks: [ 'core/paragraph', 'core/image' ],
153
- template: [
154
- [
155
- 'core/paragraph',
156
- {
157
- content: 'TestIconColors',
158
- },
159
- ],
142
+ edit: function Edit() {
143
+ const blockProps = useBlockProps( {
144
+ className: 'test-dash-icon-colors',
145
+ style: { outline: '1px solid gray', padding: 5 },
146
+ } );
147
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
148
+ allowedBlocks: [ 'core/paragraph', 'core/image' ],
149
+ template: [
150
+ [
151
+ 'core/paragraph',
152
+ {
153
+ content: 'TestIconColors',
154
+ },
160
155
  ],
161
- } )
162
- );
156
+ ],
157
+ } );
158
+ return el( 'div', innerBlocksProps );
163
159
  },
164
160
 
165
161
  save() {
@@ -175,6 +171,7 @@
175
171
  } );
176
172
 
177
173
  registerBlockType( 'test/test-svg-icon-background', {
174
+ apiVersion: 3,
178
175
  title: 'TestSvgIconBackground',
179
176
  icon: {
180
177
  background: '#010000',
@@ -182,25 +179,23 @@
182
179
  },
183
180
  category: 'text',
184
181
 
185
- edit() {
186
- return el(
187
- 'div',
188
- {
189
- className: 'test-svg-icon-background',
190
- style: { outline: '1px solid gray', padding: 5 },
191
- },
192
- el( InnerBlocks, {
193
- allowedBlocks: [ 'core/paragraph', 'core/image' ],
194
- template: [
195
- [
196
- 'core/paragraph',
197
- {
198
- content: 'TestIconColors',
199
- },
200
- ],
182
+ edit: function Edit() {
183
+ const blockProps = useBlockProps( {
184
+ className: 'test-svg-icon-background',
185
+ style: { outline: '1px solid gray', padding: 5 },
186
+ } );
187
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
188
+ allowedBlocks: [ 'core/paragraph', 'core/image' ],
189
+ template: [
190
+ [
191
+ 'core/paragraph',
192
+ {
193
+ content: 'TestIconColors',
194
+ },
201
195
  ],
202
- } )
203
- );
196
+ ],
197
+ } );
198
+ return el( 'div', innerBlocksProps );
204
199
  },
205
200
 
206
201
  save() {
@@ -1,15 +1,18 @@
1
1
  ( function () {
2
- const { InnerBlocks } = wp.blockEditor;
2
+ const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
3
3
  const { createElement: el } = wp.element;
4
4
  const { registerBlockType } = wp.blocks;
5
5
 
6
6
  registerBlockType( 'test/child-blocks-unrestricted-parent', {
7
+ apiVersion: 3,
7
8
  title: 'Child Blocks Unrestricted Parent',
8
9
  icon: 'carrot',
9
10
  category: 'text',
10
11
 
11
- edit() {
12
- return el( 'div', {}, el( InnerBlocks ) );
12
+ edit: function Edit() {
13
+ const blockProps = useBlockProps();
14
+ const innerBlocksProps = useInnerBlocksProps( blockProps );
15
+ return el( 'div', innerBlocksProps );
13
16
  },
14
17
 
15
18
  save() {
@@ -18,18 +21,17 @@
18
21
  } );
19
22
 
20
23
  registerBlockType( 'test/child-blocks-restricted-parent', {
24
+ apiVersion: 3,
21
25
  title: 'Child Blocks Restricted Parent',
22
26
  icon: 'carrot',
23
27
  category: 'text',
24
28
 
25
- edit() {
26
- return el(
27
- 'div',
28
- {},
29
- el( InnerBlocks, {
30
- allowedBlocks: [ 'core/paragraph', 'core/image' ],
31
- } )
32
- );
29
+ edit: function Edit() {
30
+ const blockProps = useBlockProps();
31
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
32
+ allowedBlocks: [ 'core/paragraph', 'core/image' ],
33
+ } );
34
+ return el( 'div', innerBlocksProps );
33
35
  },
34
36
 
35
37
  save() {
@@ -38,6 +40,7 @@
38
40
  } );
39
41
 
40
42
  registerBlockType( 'test/child-blocks-child', {
43
+ apiVersion: 3,
41
44
  title: 'Child Blocks Child',
42
45
  icon: 'carrot',
43
46
  category: 'text',
@@ -47,8 +50,9 @@
47
50
  'test/child-blocks-restricted-parent',
48
51
  ],
49
52
 
50
- edit() {
51
- return el( 'div', {}, 'Child' );
53
+ edit: function Edit() {
54
+ const blockProps = useBlockProps();
55
+ return el( 'div', blockProps, 'Child' );
52
56
  },
53
57
 
54
58
  save() {
@@ -1,13 +1,19 @@
1
1
  ( function () {
2
+ const { useBlockProps, useInnerBlocksProps } = wp.blockEditor;
3
+ const { createElement: el } = wp.element;
4
+
2
5
  wp.blocks.registerBlockType( 'test/container-without-paragraph', {
6
+ apiVersion: 3,
3
7
  title: 'Container without paragraph',
4
8
  category: 'text',
5
9
  icon: 'yes',
6
10
 
7
- edit() {
8
- return wp.element.createElement( wp.blockEditor.InnerBlocks, {
11
+ edit: function Edit() {
12
+ const blockProps = useBlockProps();
13
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
9
14
  allowedBlocks: [ 'core/image', 'core/gallery' ],
10
15
  } );
16
+ return el( 'div', innerBlocksProps );
11
17
  },
12
18
 
13
19
  save() {
@@ -5,6 +5,7 @@
5
5
  const { useRefEffect } = compose;
6
6
 
7
7
  registerBlockType( 'test/iframed-block', {
8
+ apiVersion: 3,
8
9
  edit: function Edit() {
9
10
  const ref = useRefEffect( ( node ) => {
10
11
  $( node ).test();
@@ -1,7 +1,7 @@
1
1
  ( function () {
2
2
  const registerBlockType = wp.blocks.registerBlockType;
3
3
  const el = wp.element.createElement;
4
- const InnerBlocks = wp.blockEditor.InnerBlocks;
4
+ const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
5
5
  const __ = wp.i18n.__;
6
6
  const TEMPLATE = [
7
7
  [
@@ -19,15 +19,18 @@
19
19
  };
20
20
 
21
21
  registerBlockType( 'test/test-inner-blocks-locking-all-embed', {
22
+ apiVersion: 3,
22
23
  title: 'Test Inner Blocks Locking All Embed',
23
24
  icon: 'cart',
24
25
  category: 'text',
25
26
 
26
- edit() {
27
- return el( InnerBlocks, {
27
+ edit: function Edit() {
28
+ const blockProps = useBlockProps();
29
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
28
30
  template: TEMPLATE,
29
31
  templateLock: 'all',
30
32
  } );
33
+ return el( 'div', innerBlocksProps );
31
34
  },
32
35
 
33
36
  save,
@@ -1,7 +1,7 @@
1
1
  ( function () {
2
2
  const { registerBlockType } = wp.blocks;
3
3
  const { createElement: el } = wp.element;
4
- const { InnerBlocks } = wp.blockEditor;
4
+ const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
5
5
 
6
6
  const divProps = {
7
7
  className: 'product',
@@ -16,34 +16,38 @@
16
16
  return el( 'div', divProps, el( InnerBlocks.Content ) );
17
17
  };
18
18
  registerBlockType( 'test/prioritized-inserter-blocks-unset', {
19
+ apiVersion: 3,
19
20
  title: 'Prioritized Inserter Blocks Unset',
20
21
  icon: 'carrot',
21
22
  category: 'text',
22
23
 
23
- edit() {
24
- return el( 'div', divProps, el( InnerBlocks, { template } ) );
24
+ edit: function Edit() {
25
+ const blockProps = useBlockProps( divProps );
26
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
27
+ template,
28
+ } );
29
+ return el( 'div', innerBlocksProps );
25
30
  },
26
31
 
27
32
  save,
28
33
  } );
29
34
 
30
35
  registerBlockType( 'test/prioritized-inserter-blocks-set', {
36
+ apiVersion: 3,
31
37
  title: 'Prioritized Inserter Blocks Set',
32
38
  icon: 'carrot',
33
39
  category: 'text',
34
- edit() {
35
- return el(
36
- 'div',
37
- divProps,
38
- el( InnerBlocks, {
39
- template,
40
- prioritizedInserterBlocks: [
41
- 'core/audio',
42
- 'core/spacer',
43
- 'core/code',
44
- ],
45
- } )
46
- );
40
+ edit: function Edit() {
41
+ const blockProps = useBlockProps( divProps );
42
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
43
+ template,
44
+ prioritizedInserterBlocks: [
45
+ 'core/audio',
46
+ 'core/spacer',
47
+ 'core/code',
48
+ ],
49
+ } );
50
+ return el( 'div', innerBlocksProps );
47
51
  },
48
52
 
49
53
  save,
@@ -52,28 +56,27 @@
52
56
  registerBlockType(
53
57
  'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks',
54
58
  {
59
+ apiVersion: 3,
55
60
  title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks',
56
61
  icon: 'carrot',
57
62
  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
- );
63
+ edit: function Edit() {
64
+ const blockProps = useBlockProps( divProps );
65
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
66
+ template,
67
+ allowedBlocks: [
68
+ 'core/spacer',
69
+ 'core/code',
70
+ 'core/paragraph',
71
+ 'core/heading',
72
+ ],
73
+ prioritizedInserterBlocks: [
74
+ 'core/audio', // this is **not** in the allowedBlocks list
75
+ 'core/spacer',
76
+ 'core/code',
77
+ ],
78
+ } );
79
+ return el( 'div', innerBlocksProps );
77
80
  },
78
81
 
79
82
  save,
@@ -2,7 +2,7 @@
2
2
  const { wp } = window;
3
3
  const { registerBlockType } = wp.blocks;
4
4
  const { createElement: el } = wp.element;
5
- const { InnerBlocks } = wp.blockEditor;
5
+ const { InnerBlocks, useBlockProps, useInnerBlocksProps } = wp.blockEditor;
6
6
  const { useSelect } = wp.data;
7
7
 
8
8
  const allowedBlocks = [ 'core/quote', 'core/video' ];
@@ -55,19 +55,20 @@
55
55
  }
56
56
 
57
57
  registerBlockType( 'test/inner-blocks-render-appender', {
58
+ apiVersion: 3,
58
59
  title: 'InnerBlocks renderAppender',
59
60
  icon: 'carrot',
60
61
  category: 'text',
61
62
 
62
- edit() {
63
- return el(
64
- 'div',
65
- { style: { outline: '1px solid gray', padding: 5 } },
66
- el( InnerBlocks, {
67
- allowedBlocks,
68
- renderAppender: myCustomAppender,
69
- } )
70
- );
63
+ edit: function Edit() {
64
+ const blockProps = useBlockProps( {
65
+ style: { outline: '1px solid gray', padding: 5 },
66
+ } );
67
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
68
+ allowedBlocks,
69
+ renderAppender: myCustomAppender,
70
+ } );
71
+ return el( 'div', innerBlocksProps );
71
72
  },
72
73
 
73
74
  save() {
@@ -80,14 +81,15 @@
80
81
  } );
81
82
 
82
83
  registerBlockType( 'test/inner-blocks-render-appender-dynamic', {
84
+ apiVersion: 3,
83
85
  title: 'InnerBlocks renderAppender dynamic',
84
86
  icon: 'carrot',
85
87
  category: 'text',
86
88
 
87
- edit( props ) {
88
- // Disable reason: this is a react component, but the rule of hook
89
- // fails because the block's edit function has a lowercase 'e'.
90
- // eslint-disable-next-line react-hooks/rules-of-hooks
89
+ edit: function Edit( props ) {
90
+ const blockProps = useBlockProps( {
91
+ style: { outline: '1px solid gray', padding: 5 },
92
+ } );
91
93
  const numberOfChildren = useSelect(
92
94
  ( select ) => {
93
95
  const { getBlockOrder } = select( 'core/block-editor' );
@@ -107,14 +109,11 @@
107
109
  renderAppender = multipleBlockAppender;
108
110
  break;
109
111
  }
110
- return el(
111
- 'div',
112
- { style: { outline: '1px solid gray', padding: 5 } },
113
- el( InnerBlocks, {
114
- allowedBlocks,
115
- renderAppender,
116
- } )
117
- );
112
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
113
+ allowedBlocks,
114
+ renderAppender,
115
+ } );
116
+ return el( 'div', innerBlocksProps );
118
117
  },
119
118
 
120
119
  save() {
@@ -1,8 +1,10 @@
1
1
  ( function () {
2
2
  const registerBlockType = wp.blocks.registerBlockType;
3
3
  const el = wp.element.createElement;
4
+ const { useBlockProps } = wp.blockEditor;
4
5
 
5
6
  registerBlockType( 'test/test-meta-attribute-block-early', {
7
+ apiVersion: 3,
6
8
  title: 'Test Meta Attribute Block (Early Registration)',
7
9
  icon: 'star',
8
10
  category: 'text',
@@ -15,14 +17,15 @@
15
17
  },
16
18
  },
17
19
 
18
- edit( props ) {
19
- return el( 'input', {
20
+ edit: function Edit( props ) {
21
+ const blockProps = useBlockProps( {
20
22
  className: 'my-meta-input',
21
23
  value: props.attributes.content,
22
24
  onChange( event ) {
23
25
  props.setAttributes( { content: event.target.value } );
24
26
  },
25
27
  } );
28
+ return el( 'input', blockProps );
26
29
  },
27
30
 
28
31
  save() {
@@ -1,8 +1,10 @@
1
1
  ( function () {
2
2
  const registerBlockType = wp.blocks.registerBlockType;
3
3
  const el = wp.element.createElement;
4
+ const { useBlockProps } = wp.blockEditor;
4
5
 
5
6
  registerBlockType( 'test/test-meta-attribute-block-late', {
7
+ apiVersion: 3,
6
8
  title: 'Test Meta Attribute Block (Late Registration)',
7
9
  icon: 'star',
8
10
  category: 'text',
@@ -15,14 +17,15 @@
15
17
  },
16
18
  },
17
19
 
18
- edit( props ) {
19
- return el( 'input', {
20
+ edit: function Edit( props ) {
21
+ const blockProps = useBlockProps( {
20
22
  className: 'my-meta-input',
21
23
  value: props.attributes.content,
22
24
  onChange( event ) {
23
25
  props.setAttributes( { content: event.target.value } );
24
26
  },
25
27
  } );
28
+ return el( 'input', blockProps );
26
29
  },
27
30
 
28
31
  save() {
@@ -33,6 +33,7 @@ function enqueue_test_meta_attribute_block() {
33
33
  plugins_url( 'meta-attribute-block/early.js', __FILE__ ),
34
34
  array(
35
35
  'wp-blocks',
36
+ 'wp-block-editor',
36
37
  'wp-element',
37
38
  ),
38
39
  filemtime( plugin_dir_path( __FILE__ ) . 'meta-attribute-block/early.js' )
@@ -43,6 +44,7 @@ function enqueue_test_meta_attribute_block() {
43
44
  plugins_url( 'meta-attribute-block/late.js', __FILE__ ),
44
45
  array(
45
46
  'wp-blocks',
47
+ 'wp-block-editor',
46
48
  'wp-element',
47
49
  ),
48
50
  filemtime( plugin_dir_path( __FILE__ ) . 'meta-attribute-block/late.js' ),