diff --git a/blocks/api/raw-handling/test/integration/evernote-out.html b/blocks/api/raw-handling/test/integration/evernote-out.html index 70d1649dba5b14..2b52f5d7e413e2 100644 --- a/blocks/api/raw-handling/test/integration/evernote-out.html +++ b/blocks/api/raw-handling/test/integration/evernote-out.html @@ -56,5 +56,5 @@ -
+
diff --git a/blocks/api/raw-handling/test/integration/google-docs-out.html b/blocks/api/raw-handling/test/integration/google-docs-out.html index 8cb94dc1bbcb80..d8242c4779198e 100644 --- a/blocks/api/raw-handling/test/integration/google-docs-out.html +++ b/blocks/api/raw-handling/test/integration/google-docs-out.html @@ -60,6 +60,6 @@

This is a heading

-
+
diff --git a/blocks/api/raw-handling/test/integration/ms-word-online-out.html b/blocks/api/raw-handling/test/integration/ms-word-online-out.html index afb5993ecff3f2..d7d6370dfc3baf 100644 --- a/blocks/api/raw-handling/test/integration/ms-word-online-out.html +++ b/blocks/api/raw-handling/test/integration/ms-word-online-out.html @@ -50,5 +50,5 @@ -
+
diff --git a/blocks/api/raw-handling/test/integration/ms-word-out.html b/blocks/api/raw-handling/test/integration/ms-word-out.html index 02fbf89801c1b7..b5d2e6ba1ca548 100644 --- a/blocks/api/raw-handling/test/integration/ms-word-out.html +++ b/blocks/api/raw-handling/test/integration/ms-word-out.html @@ -85,5 +85,5 @@

This is a heading level 2

-
+
diff --git a/blocks/api/raw-handling/test/integration/one-image-out.html b/blocks/api/raw-handling/test/integration/one-image-out.html index c21d50b34c57de..a346512ebb253d 100644 --- a/blocks/api/raw-handling/test/integration/one-image-out.html +++ b/blocks/api/raw-handling/test/integration/one-image-out.html @@ -1,3 +1,3 @@ -
+
diff --git a/blocks/api/raw-handling/test/integration/two-images-out.html b/blocks/api/raw-handling/test/integration/two-images-out.html index 03cb3052b1f22c..8d0d93c44843fd 100644 --- a/blocks/api/raw-handling/test/integration/two-images-out.html +++ b/blocks/api/raw-handling/test/integration/two-images-out.html @@ -1,7 +1,7 @@ -
+
-
+
diff --git a/blocks/test/fixtures/core__image.serialized.html b/blocks/test/fixtures/core__image.serialized.html index fb41212fe367e1..bbe320d2bc1404 100644 --- a/blocks/test/fixtures/core__image.serialized.html +++ b/blocks/test/fixtures/core__image.serialized.html @@ -1,3 +1,3 @@ -
+
diff --git a/blocks/test/fixtures/core__image__center-caption.serialized.html b/blocks/test/fixtures/core__image__center-caption.serialized.html index 29875b3cf77599..47d89c059a193b 100644 --- a/blocks/test/fixtures/core__image__center-caption.serialized.html +++ b/blocks/test/fixtures/core__image__center-caption.serialized.html @@ -1,5 +1,5 @@ -
+
Give it a try. Press the "really wide" button on the image toolbar.
diff --git a/element/serialize.js b/element/serialize.js index dac7b155e9a75a..9b9c67552ffa81 100644 --- a/element/serialize.js +++ b/element/serialize.js @@ -495,11 +495,6 @@ export function renderAttributes( props ) { continue; } - // Empty values are only rendered if for a meaningful attribute. - if ( ! value && ! isMeaningfulAttribute ) { - continue; - } - result += ' ' + attribute; // Boolean attributes should write attribute name, but without value. @@ -526,7 +521,7 @@ export function renderAttributes( props ) { * @return {string} Style attribute value. */ export function renderStyle( style ) { - let result = ''; + let result; for ( const property in style ) { const value = style[ property ]; @@ -536,6 +531,8 @@ export function renderStyle( style ) { if ( result ) { result += ';'; + } else { + result = ''; } result += kebabCase( property ) + ':' + getNormalStyleValue( property, value ); diff --git a/element/test/serialize.js b/element/test/serialize.js index 4f506d2707cc38..d95b38692309d3 100644 --- a/element/test/serialize.js +++ b/element/test/serialize.js @@ -74,14 +74,14 @@ describe( 'serialize()', () => { expect( result ).toBe( '' ); } ); - it( 'should render an empty "as-is" attribute', () => { - const result = serialize(