@@ -243,7 +243,7 @@ export function stringify( node, selectionOrPositionOrRange = null ) {
243243 * @param {Object } [options={}] Additional configuration.
244244 * @param {Array<Object> } [options.selectionAttributes] List of attributes which will be passed to the selection.
245245 * @param {Boolean } [options.lastRangeBackward=false] If set to true last range will be added as backward.
246- * @param {module:engine/model/schema~SchemaPath } [options.context=[ '$root' ]] The conversion context.
246+ * @param {module:engine/model/schema~SchemaContextDefinition } [options.context=[ '$root' ]] The conversion context.
247247 * If not provided default `[ '$root' ]` will be used.
248248 * @returns {module:engine/model/element~Element|module:engine/model/text~Text|
249249 * module:engine/model/documentfragment~DocumentFragment|Object} Returns parsed model node or
@@ -329,14 +329,10 @@ function convertToModelFragment() {
329329
330330function convertToModelElement ( ) {
331331 return ( evt , data , consumable , conversionApi ) => {
332- const schemaQuery = {
333- name : data . input . name ,
334- attributes : Array . from ( data . input . getAttributeKeys ( ) ) ,
335- inside : data . context
336- } ;
337-
338- if ( ! conversionApi . schema . check ( schemaQuery ) ) {
339- throw new Error ( `Element '${ schemaQuery . name } ' not allowed in context ${ JSON . stringify ( data . context ) } .` ) ;
332+ const elementName = data . input . name ;
333+
334+ if ( ! conversionApi . schema . checkChild ( data . context , elementName ) ) {
335+ throw new Error ( `Element '${ elementName } ' was not allowed in context ${ JSON . stringify ( data . context ) } .` ) ;
340336 }
341337
342338 // View attribute value is a string so we want to typecast it to the original type.
@@ -356,13 +352,8 @@ function convertToModelElement() {
356352
357353function convertToModelText ( withAttributes = false ) {
358354 return ( evt , data , consumable , conversionApi ) => {
359- const schemaQuery = {
360- name : '$text' ,
361- inside : data . context
362- } ;
363-
364- if ( ! conversionApi . schema . check ( schemaQuery ) ) {
365- throw new Error ( `Element '${ schemaQuery . name } ' not allowed in context ${ JSON . stringify ( data . context ) } .` ) ;
355+ if ( ! conversionApi . schema . checkChild ( data . context , '$text' ) ) {
356+ throw new Error ( `Text was not allowed in context ${ JSON . stringify ( data . context ) } .` ) ;
366357 }
367358
368359 let node ;
0 commit comments