Skip to content

Commit

Permalink
Update with suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed May 27, 2024
1 parent b3dcbff commit b7b6da8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 13 deletions.
13 changes: 1 addition & 12 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,7 @@ $block-inserter-tabs-height: 44px;
overflow: hidden;

.block-editor-inserter__tablist {
width: 100%;

button[role="tab"] {
flex-grow: 1;
margin-bottom: -$border-width;
&[id$="reusable"] {
flex-grow: inherit;
// These are to align the `reusable` icon with the search icon.
padding-left: $grid-unit-20;
padding-right: $grid-unit-20;
}
}
margin-bottom: -$border-width;
}

.block-editor-inserter__tabpanel {
Expand Down
14 changes: 14 additions & 0 deletions packages/e2e-tests/plugins/interactive-blocks/namespace/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@
<div data-wp-interactive>
<a data-wp-bind--href="other::state.url" data-testid="other namespace"></a>
</div>

<div data-wp-interactive="true">
<a data-wp-bind--href="state.url" data-testid="true namespace"></a>
</div>

<div data-wp-interactive="false">
<a data-wp-bind--href="state.url" data-testid="false namespace"></a>
</div>
<div data-wp-interactive="[]">
<a data-wp-bind--href="state.url" data-testid="[] namespace"></a>
</div>
<div data-wp-interactive='"quoted string"'>
<a data-wp-bind--href="state.url" data-testid="quoted namespace"></a>
</div>
29 changes: 29 additions & 0 deletions packages/e2e-tests/plugins/interactive-blocks/namespace/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,32 @@ store( '{}', {
url: '/other-store-url',
},
} );

store( 'true', {
state: {
url: '/some-url',
},
} );

store( 'false', {
state: {
url: '/some-url',
},
} );

store( '[]', {
state: {
url: '/some-url',
},
} );

store( '"quoted string"', {
state: {
url: '/some-url',
},
} );





2 changes: 1 addition & 1 deletion packages/interactivity/src/vdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function toVdom( root: Node ): Array< ComponentChild > {
try {
const parsedValue = JSON.parse( value );
value = isObject( parsedValue ) ? parsedValue : value;
} catch ( e ) {}
} catch {}
if ( attributeName === islandAttr ) {
island = true;
const islandNamespace =
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/specs/interactivity/namespace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,28 @@ test.describe( 'Namespaces', () => {
const el = page.getByTestId( 'null namespace' );
await expect( el ).toHaveAttribute( 'href', '/some-url' );
} );

test( 'A true as a string as namespace should work', async ( { page } ) => {
const el = page.getByTestId( 'true namespace' );
await expect( el ).toHaveAttribute( 'href', '/some-url' );
} );

test( 'A false as a string as namespace should work', async ( {
page,
} ) => {
const el = page.getByTestId( 'false namespace' );
await expect( el ).toHaveAttribute( 'href', '/some-url' );
} );

test( 'A [] as a string as namespace should work', async ( { page } ) => {
const el = page.getByTestId( '[] namespace' );
await expect( el ).toHaveAttribute( 'href', '/some-url' );
} );

test( 'A "quoted string" as a string as namespace should work', async ( {
page,
} ) => {
const el = page.getByTestId( 'quoted namespace' );
await expect( el ).toHaveAttribute( 'href', '/some-url' );
} );
} );

0 comments on commit b7b6da8

Please sign in to comment.