Skip to content

Commit

Permalink
Fix raw matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Dec 20, 2023
1 parent dba904b commit 3b20769
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ _Parameters_
- _blockTypeOrName_ `string|Object`: Block type or name.
- _innerHTML_ `string|Node`: Raw block content.
- _attributes_ `?Object`: Known block attributes (from delimiters).
- _innerDom_ `?Node`: Raw block content parsed into DOM.

_Returns_

Expand Down
8 changes: 4 additions & 4 deletions packages/blocks/src/api/parser/get-block-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ export function parseWithAttributeSchema( innerHTML, attributeSchema ) {
* @param {string|Object} blockTypeOrName Block type or name.
* @param {string|Node} innerHTML Raw block content.
* @param {?Object} attributes Known block attributes (from delimiters).
*
* @param {?Node} innerDom Raw block content parsed into DOM.
* @return {Object} All block attributes.
*/
export function getBlockAttributes(
blockTypeOrName,
innerHTML,
attributes = {}
attributes = {},
innerDom
) {
const doc =
typeof innerHTML === 'string' ? parseHtml( innerHTML ) : innerHTML;
const doc = innerDom ? innerDom : parseHtml( innerHTML );
const blockType = normalizeBlockType( blockTypeOrName );

const blockAttributes = Object.fromEntries(
Expand Down
5 changes: 3 additions & 2 deletions packages/blocks/src/api/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ export function parseRawBlock( rawBlock, options ) {
normalizedBlock.blockName,
getBlockAttributes(
blockType,
normalizedBlock.innerDom,
normalizedBlock.attrs
normalizedBlock.innerHTML,
normalizedBlock.attrs,
normalizedBlock.innerDom
),
parsedInnerBlocks
);
Expand Down

0 comments on commit 3b20769

Please sign in to comment.