Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Dec 21, 2017
1 parent 2bb8c02 commit fa4ad03
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/model/schema2.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,15 @@ function compileAllowWhere( compiledRules, itemName ) {
}

function compileAllowAttributesOf( compiledRules, itemName ) {
// for ( const allowAttributeOfItem of compiledRules[ itemName ].allowAttributesOf ) {
// const inheritFrom = compiledRules[ allowAttributeOfItem ];
// }
for ( const allowAttributeOfItem of compiledRules[ itemName ].allowAttributesOf ) {
const inheritFrom = compiledRules[ allowAttributeOfItem ];

if ( inheritFrom ) {
const inheritAttributes = inheritFrom.allowAttributes;

compiledRules[ itemName ].allowAttributes.push( ...inheritAttributes );
}
}

delete compiledRules[ itemName ].allowAttributesOf;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/model/schema/schema2.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ describe( 'Schema', () => {
allowAttributes: [ 'foo' ]
} );
} );

it( 'ensures no duplicates in allowAttributes duplicated by allowAttributesOf', () => {
schema.register( 'paragraph', {
allowAttributes: 'foo',
allowAttributesOf: '$block'
} );
schema.register( '$block', {
allowAttributes: 'foo'
} );

const rules = schema.getRules();

expect( rules.paragraph ).to.deep.equal( {
name: 'paragraph',
allowIn: [],
allowAttributes: [ 'foo' ]
} );
} );
} );

describe( 'checkChild()', () => {
Expand Down

0 comments on commit fa4ad03

Please sign in to comment.