@wordpress/e2e-tests 7.16.0 → 7.18.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +8 -7
  3. package/plugins/block-icons/index.js +1 -1
  4. package/plugins/dataviews.php +25 -0
  5. package/plugins/interactive-blocks/directive-bind/render.php +3 -1
  6. package/plugins/interactive-blocks/directive-bind/view.js +32 -29
  7. package/plugins/interactive-blocks/directive-body/render.php +3 -1
  8. package/plugins/interactive-blocks/directive-body/view.js +11 -9
  9. package/plugins/interactive-blocks/directive-class/render.php +3 -1
  10. package/plugins/interactive-blocks/directive-class/view.js +20 -18
  11. package/plugins/interactive-blocks/directive-context/render.php +6 -4
  12. package/plugins/interactive-blocks/directive-context/view.js +49 -40
  13. package/plugins/interactive-blocks/directive-init/render.php +8 -6
  14. package/plugins/interactive-blocks/directive-init/view.js +59 -60
  15. package/plugins/interactive-blocks/directive-key/render.php +5 -1
  16. package/plugins/interactive-blocks/directive-key/view.js +18 -14
  17. package/plugins/interactive-blocks/directive-on/render.php +3 -1
  18. package/plugins/interactive-blocks/directive-on/view.js +27 -24
  19. package/plugins/interactive-blocks/directive-priorities/render.php +7 -2
  20. package/plugins/interactive-blocks/directive-priorities/view.js +107 -111
  21. package/plugins/interactive-blocks/directive-slots/render.php +3 -1
  22. package/plugins/interactive-blocks/directive-slots/view.js +17 -15
  23. package/plugins/interactive-blocks/directive-style/render.php +2 -1
  24. package/plugins/interactive-blocks/directive-style/view.js +21 -19
  25. package/plugins/interactive-blocks/directive-text/render.php +3 -1
  26. package/plugins/interactive-blocks/directive-text/view.js +16 -14
  27. package/plugins/interactive-blocks/{store-afterload → directive-watch}/block.json +3 -3
  28. package/plugins/interactive-blocks/{directive-effect → directive-watch}/render.php +8 -6
  29. package/plugins/interactive-blocks/directive-watch/view.js +53 -0
  30. package/plugins/interactive-blocks/negation-operator/render.php +4 -2
  31. package/plugins/interactive-blocks/negation-operator/view.js +15 -19
  32. package/plugins/interactive-blocks/router-navigate/render.php +11 -8
  33. package/plugins/interactive-blocks/router-navigate/view.js +27 -34
  34. package/plugins/interactive-blocks/router-regions/render.php +13 -3
  35. package/plugins/interactive-blocks/router-regions/view.js +37 -35
  36. package/plugins/interactive-blocks/store-tag/render.php +7 -4
  37. package/plugins/interactive-blocks/store-tag/view.js +19 -19
  38. package/plugins/interactive-blocks/tovdom/render.php +3 -1
  39. package/plugins/interactive-blocks/tovdom/view.js +5 -4
  40. package/plugins/interactive-blocks/tovdom-islands/render.php +11 -6
  41. package/plugins/interactive-blocks/tovdom-islands/view.js +24 -23
  42. package/plugins/interactive-blocks.php +4 -4
  43. package/specs/editor/various/datepicker.test.js +8 -8
  44. package/specs/editor/various/pattern-blocks.test.js +4 -4
  45. package/specs/editor/various/scheduling.test.js +1 -1
  46. package/plugins/interactive-blocks/directive-effect/block.json +0 -14
  47. package/plugins/interactive-blocks/directive-effect/view.js +0 -59
  48. package/plugins/interactive-blocks/store-afterload/render.php +0 -41
  49. package/plugins/interactive-blocks/store-afterload/view.js +0 -60
  50. package/specs/editor/plugins/__snapshots__/align-hook.test.js.snap +0 -43
  51. package/specs/editor/plugins/__snapshots__/block-directory-add.test.js.snap +0 -3
  52. package/specs/editor/plugins/__snapshots__/container-blocks.test.js.snap +0 -58
  53. package/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap +0 -147
  54. package/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap +0 -25
  55. package/specs/editor/plugins/__snapshots__/meta-attribute-block.test.js.snap +0 -9
  56. package/specs/editor/plugins/__snapshots__/plugins-api.test.js.snap +0 -7
  57. package/specs/editor/plugins/align-hook.test.js +0 -234
  58. package/specs/editor/plugins/annotations.test.js +0 -189
  59. package/specs/editor/plugins/block-directory-add.test.js +0 -205
  60. package/specs/editor/plugins/block-icons.test.js +0 -170
  61. package/specs/editor/plugins/child-blocks.test.js +0 -66
  62. package/specs/editor/plugins/container-blocks.test.js +0 -130
  63. package/specs/editor/plugins/cpt-locking.test.js +0 -251
  64. package/specs/editor/plugins/custom-taxonomies.test.js +0 -61
  65. package/specs/editor/plugins/inner-blocks-prioritized-inserter-blocks.test.js +0 -132
  66. package/specs/editor/plugins/inner-blocks-render-appender.test.js +0 -126
  67. package/specs/editor/plugins/meta-attribute-block.test.js +0 -100
  68. package/specs/editor/plugins/meta-boxes.test.js +0 -137
  69. package/specs/editor/plugins/plugins-api.test.js +0 -189
  70. package/specs/editor/various/is-typing.test.js +0 -101
  71. package/specs/editor/various/publish-button.test.js +0 -46
  72. package/specs/editor/various/sidebar-permalink.test.js +0 -53
@@ -1,27 +1,30 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- state: {
6
- counter: 0,
7
- text: ''
6
+ const { state } = store( 'directive-on', {
7
+ state: {
8
+ counter: 0,
9
+ text: '',
10
+ },
11
+ actions: {
12
+ clickHandler: ( event ) => {
13
+ state.counter += 1;
14
+ event.target.dispatchEvent(
15
+ new CustomEvent( 'customevent', { bubbles: true } )
16
+ );
8
17
  },
9
- actions: {
10
- clickHandler: ( { state, event } ) => {
11
- state.counter += 1;
12
- event.target.dispatchEvent(
13
- new CustomEvent( 'customevent', { bubbles: true } )
14
- );
15
- },
16
- inputHandler: ( { state, event } ) => {
17
- state.text = event.target.value;
18
- },
19
- selectHandler: ( { context, event } ) => {
20
- context.option = event.target.value;
21
- },
22
- customEventHandler: ({ context }) => {
23
- context.customEvents += 1;
24
- },
18
+ inputHandler: ( event ) => {
19
+ state.text = event.target.value;
25
20
  },
26
- } );
27
- } )( window );
21
+ selectHandler: ( event ) => {
22
+ const context = getContext();
23
+ context.option = event.target.value;
24
+ },
25
+ customEventHandler: () => {
26
+ const context = getContext();
27
+ context.customEvents += 1;
28
+ },
29
+ },
30
+ } );
@@ -5,8 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-priorities-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "directive-priorities" }'>
10
12
  <pre data-testid="execution order"></pre>
11
13
 
12
14
  <!-- Element with test directives -->
@@ -20,5 +22,8 @@
20
22
  </div>
21
23
 
22
24
  <div data-testid="non-existent-directives">
23
- <div data-wp-interactive ><div data-wp-non-existent-directive></div></div>
25
+ <!-- WARNING: the `div` with `data-wp-non-existent-directive` should remain
26
+ inline (i.e., without new line or blank characters in between) to
27
+ ensure it is the only child node. Otherwise, tests could fail. -->
28
+ <div data-wp-interactive='{ "namespace": "directive-priorities" }'><div data-wp-non-existent-directive></div></div>
24
29
  </div>
@@ -1,121 +1,117 @@
1
- ( ( { wp } ) => {
2
- /**
3
- * WordPress dependencies
4
- */
5
- const {
6
- store,
7
- directive,
8
- deepSignal,
9
- useContext,
10
- useEffect,
11
- createElement: h
12
- } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ store,
6
+ getContext,
7
+ directive,
8
+ deepSignal,
9
+ useEffect,
10
+ createElement as h,
11
+ } from '@wordpress/interactivity';
13
12
 
14
- /**
15
- * Util to check that render calls happen in order.
16
- *
17
- * @param {string} n Name passed from the directive being executed.
18
- */
19
- const executionProof = ( n ) => {
20
- const el = document.querySelector( '[data-testid="execution order"]' );
21
- if ( ! el.textContent ) el.textContent = n;
22
- else el.textContent += `, ${ n }`;
23
- };
13
+ /**
14
+ * Namespace used in custom directives and store.
15
+ */
16
+ const namespace = 'directive-priorities';
24
17
 
25
- /**
26
- * Simple context directive, just for testing purposes. It provides a deep
27
- * signal with these two properties:
28
- * - attribute: 'from context'
29
- * - text: 'from context'
30
- */
31
- directive(
32
- 'test-context',
33
- ( { context: { Provider }, props: { children } } ) => {
34
- executionProof( 'context' );
35
- const value = deepSignal( {
18
+ /**
19
+ * Util to check that render calls happen in order.
20
+ *
21
+ * @param {string} n Name passed from the directive being executed.
22
+ */
23
+ const executionProof = ( n ) => {
24
+ const el = document.querySelector( '[data-testid="execution order"]' );
25
+ if ( ! el.textContent ) el.textContent = n;
26
+ else el.textContent += `, ${ n }`;
27
+ };
28
+
29
+ /**
30
+ * Simple context directive, just for testing purposes. It provides a deep
31
+ * signal with these two properties:
32
+ * - attribute: 'from context'
33
+ * - text: 'from context'
34
+ */
35
+ directive(
36
+ 'test-context',
37
+ ( { context: { Provider }, props: { children } } ) => {
38
+ executionProof( 'context' );
39
+ const value = deepSignal( {
40
+ [ namespace ]: {
36
41
  attribute: 'from context',
37
42
  text: 'from context',
38
- } );
39
- return h( Provider, { value }, children );
40
- },
41
- { priority: 8 }
42
- );
43
-
44
- /**
45
- * Simple attribute directive, for testing purposes. It reads the value of
46
- * `attribute` from context and populates `data-attribute` with it.
47
- */
48
- directive( 'test-attribute', ( { context, evaluate, element } ) => {
49
- executionProof( 'attribute' );
50
- const contextValue = useContext( context );
51
- const attributeValue = evaluate( 'context.attribute', {
52
- context: contextValue,
43
+ },
53
44
  } );
54
- useEffect( () => {
55
- element.ref.current.setAttribute(
56
- 'data-attribute',
57
- attributeValue,
58
- );
59
- }, [] );
60
- element.props[ 'data-attribute' ] = attributeValue;
45
+ return h( Provider, { value }, children );
46
+ },
47
+ { priority: 8 }
48
+ );
49
+
50
+ /**
51
+ * Simple attribute directive, for testing purposes. It reads the value of
52
+ * `attribute` from context and populates `data-attribute` with it.
53
+ */
54
+ directive( 'test-attribute', ( { evaluate, element } ) => {
55
+ executionProof( 'attribute' );
56
+ const attributeValue = evaluate( {
57
+ namespace,
58
+ value: 'context.attribute',
61
59
  } );
60
+ useEffect( () => {
61
+ element.ref.current.setAttribute( 'data-attribute', attributeValue );
62
+ }, [] );
63
+ element.props[ 'data-attribute' ] = attributeValue;
64
+ } );
62
65
 
63
- /**
64
- * Simple text directive, for testing purposes. It reads the value of
65
- * `text` from context and populates `children` with it.
66
- */
67
- directive(
68
- 'test-text',
69
- ( { context, evaluate, element } ) => {
70
- executionProof( 'text' );
71
- const contextValue = useContext( context );
72
- const textValue = evaluate( 'context.text', {
73
- context: contextValue,
74
- } );
75
- element.props.children =
76
- h( 'p', { 'data-testid': 'text' }, textValue );
77
- },
78
- { priority: 12 }
79
- );
66
+ /**
67
+ * Simple text directive, for testing purposes. It reads the value of
68
+ * `text` from context and populates `children` with it.
69
+ */
70
+ directive(
71
+ 'test-text',
72
+ ( { evaluate, element } ) => {
73
+ executionProof( 'text' );
74
+ const textValue = evaluate( { namespace, value: 'context.text' } );
75
+ element.props.children = h( 'p', { 'data-testid': 'text' }, textValue );
76
+ },
77
+ { priority: 12 }
78
+ );
80
79
 
81
- /**
82
- * Children directive, for testing purposes. It adds a wrapper around
83
- * `children`, including two buttons to modify `text` and `attribute` values
84
- * from the received context.
85
- */
86
- directive(
87
- 'test-children',
88
- ( { context, evaluate, element } ) => {
89
- executionProof( 'children' );
90
- const contextValue = useContext( context );
91
- const updateAttribute = () => {
92
- evaluate(
93
- 'actions.updateAttribute',
94
- { context: contextValue }
95
- );
96
- };
97
- const updateText = () => {
98
- evaluate( 'actions.updateText', { context: contextValue } );
99
- };
100
- element.props.children = h(
101
- 'div',
102
- {},
103
- element.props.children,
104
- h( 'button', { onClick: updateAttribute }, 'Update attribute' ),
105
- h( 'button', { onClick: updateText }, 'Update text' )
106
- );
107
- },
108
- { priority: 14 }
109
- );
80
+ /**
81
+ * Children directive, for testing purposes. It adds a wrapper around
82
+ * `children`, including two buttons to modify `text` and `attribute` values
83
+ * from the received context.
84
+ */
85
+ directive(
86
+ 'test-children',
87
+ ( { evaluate, element } ) => {
88
+ executionProof( 'children' );
89
+ const updateAttribute = () => {
90
+ evaluate( { namespace, value: 'actions.updateAttribute' } );
91
+ };
92
+ const updateText = () => {
93
+ evaluate( { namespace, value: 'actions.updateText' } );
94
+ };
95
+ element.props.children = h(
96
+ 'div',
97
+ {},
98
+ element.props.children,
99
+ h( 'button', { onClick: updateAttribute }, 'Update attribute' ),
100
+ h( 'button', { onClick: updateText }, 'Update text' )
101
+ );
102
+ },
103
+ { priority: 14 }
104
+ );
110
105
 
111
- store( {
112
- actions: {
113
- updateText( { context } ) {
114
- context.text = 'updated';
115
- },
116
- updateAttribute( { context } ) {
117
- context.attribute = 'updated';
118
- },
106
+ store( 'directive-priorities', {
107
+ actions: {
108
+ updateText() {
109
+ const context = getContext();
110
+ context.text = 'updated';
119
111
  },
120
- } );
121
- } )( window );
112
+ updateAttribute() {
113
+ const context = getContext();
114
+ context.attribute = 'updated';
115
+ },
116
+ },
117
+ } );
@@ -5,9 +5,11 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-slots-view' );
8
9
  ?>
10
+
9
11
  <div
10
- data-wp-interactive
12
+ data-wp-interactive='{ "namespace": "directive-slots" }'
11
13
  data-wp-slot-provider
12
14
  data-wp-context='{ "text": "fill" }'
13
15
  >
@@ -1,18 +1,20 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- state: {
6
- slot: ''
6
+ const { state } = store( 'directive-slots', {
7
+ state: {
8
+ slot: '',
9
+ },
10
+ actions: {
11
+ changeSlot( event ) {
12
+ state.slot = event.target.dataset.slot;
7
13
  },
8
- actions: {
9
- changeSlot: ( { state, event } ) => {
10
- state.slot = event.target.dataset.slot;
11
- },
12
- updateSlotText: ( { context } ) => {
13
- const n = context.text[1];
14
- context.text = `[${n} updated]`;
15
- },
14
+ updateSlotText() {
15
+ const context = getContext();
16
+ const n = context.text[ 1 ];
17
+ context.text = `[${ n } updated]`;
16
18
  },
17
- } );
18
- } )( window );
19
+ },
20
+ } );
@@ -5,9 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-style-view' );
8
9
  ?>
9
10
 
10
- <div data-wp-interactive>
11
+ <div data-wp-interactive='{ "namespace": "directive-style" }'>
11
12
  <button
12
13
  data-wp-on--click="actions.toggleColor"
13
14
  data-testid="toggle color"
@@ -1,22 +1,24 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- state: {
6
- falseValue: false,
7
- color: "red",
8
- border: "2px solid yellow"
6
+ const { state } = store( 'directive-style', {
7
+ state: {
8
+ falseValue: false,
9
+ color: 'red',
10
+ border: '2px solid yellow',
11
+ },
12
+ actions: {
13
+ toggleColor() {
14
+ state.color = state.color === 'red' ? 'blue' : 'red';
9
15
  },
10
- actions: {
11
- toggleColor: ( { state } ) => {
12
- state.color = state.color === "red" ? "blue" : "red";
13
- },
14
- switchColorToFalse: ({ state }) => {
15
- state.color = false;
16
- },
17
- toggleContext: ( { context } ) => {
18
- context.color = context.color === "red" ? "blue" : "red";
19
- },
16
+ switchColorToFalse() {
17
+ state.color = false;
20
18
  },
21
- } );
22
- } )( window );
19
+ toggleContext() {
20
+ const context = getContext();
21
+ context.color = context.color === 'red' ? 'blue' : 'red';
22
+ },
23
+ },
24
+ } );
@@ -5,8 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-text-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "directive-context" }'>
10
12
  <div>
11
13
  <span
12
14
  data-wp-text="state.text"
@@ -1,17 +1,19 @@
1
- ( ( { wp } ) => {
2
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, getContext } from '@wordpress/interactivity';
3
5
 
4
- store( {
5
- state: {
6
- text: 'Text 1',
6
+ const { state } = store( 'directive-context', {
7
+ state: {
8
+ text: 'Text 1',
9
+ },
10
+ actions: {
11
+ toggleStateText() {
12
+ state.text = state.text === 'Text 1' ? 'Text 2' : 'Text 1';
7
13
  },
8
- actions: {
9
- toggleStateText: ( { state } ) => {
10
- state.text = state.text === 'Text 1' ? 'Text 2' : 'Text 1';
11
- },
12
- toggleContextText: ( { context } ) => {
13
- context.text = context.text === 'Text 1' ? 'Text 2' : 'Text 1';
14
- },
14
+ toggleContextText() {
15
+ const context = getContext();
16
+ context.text = context.text === 'Text 1' ? 'Text 2' : 'Text 1';
15
17
  },
16
- } );
17
- } )( window );
18
+ },
19
+ } );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "apiVersion": 2,
3
- "name": "test/store-afterload",
4
- "title": "E2E Interactivity tests - store afterload",
3
+ "name": "test/directive-watch",
4
+ "title": "E2E Interactivity tests - directive watch",
5
5
  "category": "text",
6
6
  "icon": "heart",
7
7
  "description": "",
@@ -9,6 +9,6 @@
9
9
  "interactivity": true
10
10
  },
11
11
  "textdomain": "e2e-interactivity",
12
- "viewScript": "store-afterload-view",
12
+ "viewScript": "directive-watch-view",
13
13
  "render": "file:./render.php"
14
14
  }
@@ -1,29 +1,31 @@
1
1
  <?php
2
2
  /**
3
- * HTML for testing the directive `data-wp-effect`.
3
+ * HTML for testing the directive `data-wp-watch`.
4
4
  *
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'directive-watch-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "directive-watch" }'>
10
12
  <div data-wp-show-mock="state.isOpen">
11
13
  <input
12
14
  data-testid="input"
13
- data-wp-effect="effects.elementAddedToTheDOM"
15
+ data-wp-watch="callbacks.elementAddedToTheDOM"
14
16
  />
15
17
  </div>
16
18
 
17
19
  <div
18
- data-wp-text="selectors.elementInTheDOM"
20
+ data-wp-text="state.elementInTheDOM"
19
21
  data-testid="element in the DOM"
20
22
  ></div>
21
23
 
22
- <div data-wp-effect="effects.changeFocus"></div>
24
+ <div data-wp-watch="callbacks.changeFocus"></div>
23
25
 
24
26
  <div
25
27
  data-testid="short-circuit infinite loops"
26
- data-wp-effect="effects.infiniteLoop"
28
+ data-wp-watch="callbacks.infiniteLoop"
27
29
  data-wp-text="state.counter"
28
30
  >
29
31
  0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store, directive } from '@wordpress/interactivity';
5
+
6
+ // Fake `data-wp-show-mock` directive to test when things are removed from the
7
+ // DOM. Replace with `data-wp-show` when it's ready.
8
+ directive(
9
+ 'show-mock',
10
+ ( { directives: { 'show-mock': showMock }, element, evaluate } ) => {
11
+ const entry = showMock.find( ( { suffix } ) => suffix === 'default' );
12
+ if ( ! evaluate( entry ) ) return null;
13
+ return element;
14
+ }
15
+ );
16
+
17
+ const { state } = store( 'directive-watch', {
18
+ state: {
19
+ isOpen: true,
20
+ isElementInTheDOM: false,
21
+ counter: 0,
22
+ get elementInTheDOM() {
23
+ return state.isElementInTheDOM
24
+ ? 'element is in the DOM'
25
+ : 'element is not in the DOM';
26
+ },
27
+ },
28
+ actions: {
29
+ toggle() {
30
+ state.isOpen = ! state.isOpen;
31
+ },
32
+ increment() {
33
+ state.counter = state.counter + 1;
34
+ },
35
+ },
36
+ callbacks: {
37
+ elementAddedToTheDOM: () => {
38
+ state.isElementInTheDOM = true;
39
+
40
+ return () => {
41
+ state.isElementInTheDOM = false;
42
+ };
43
+ },
44
+ changeFocus: () => {
45
+ if ( state.isOpen ) {
46
+ document.querySelector( "[data-testid='input']" ).focus();
47
+ }
48
+ },
49
+ infiniteLoop: () => {
50
+ state.counter = state.counter + 1;
51
+ },
52
+ },
53
+ } );
@@ -5,8 +5,10 @@
5
5
  * @package gutenberg-test-interactive-blocks
6
6
  */
7
7
 
8
+ gutenberg_enqueue_module( 'negation-operator-view' );
8
9
  ?>
9
- <div data-wp-interactive>
10
+
11
+ <div data-wp-interactive='{ "namespace": "negation-operator" }'>
10
12
  <button
11
13
  data-wp-on--click="actions.toggle"
12
14
  data-testid="toggle active value"
@@ -20,7 +22,7 @@
20
22
  ></div>
21
23
 
22
24
  <div
23
- data-wp-bind--hidden="!selectors.active"
25
+ data-wp-bind--hidden="!state.isActive"
24
26
  data-testid="add hidden attribute if selector is not active"
25
27
  ></div>
26
28
  </div>
@@ -1,22 +1,18 @@
1
- ( ( { wp } ) => {
2
- /**
3
- * WordPress dependencies
4
- */
5
- const { store } = wp.interactivity;
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store } from '@wordpress/interactivity';
6
5
 
7
- store( {
8
- selectors: {
9
- active: ( { state } ) => {
10
- return state.active;
11
- },
6
+ const { state } = store( 'negation-operator', {
7
+ state: {
8
+ active: false,
9
+ get isActive() {
10
+ return state.active;
12
11
  },
13
- state: {
14
- active: false,
12
+ },
13
+ actions: {
14
+ toggle() {
15
+ state.active = ! state.active;
15
16
  },
16
- actions: {
17
- toggle: ( { state } ) => {
18
- state.active = ! state.active;
19
- },
20
- },
21
- } );
22
- } )( window );
17
+ },
18
+ } );