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

Commit fe6d17d

Browse files
authored
Merge pull request #1630 from ckeditor/t/1617
Fix: Converter priority passing in `conversion.attributeToElement()`. Closes #1617.
2 parents a9c41c8 + 6e44281 commit fe6d17d

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/conversion/conversion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export default class Conversion {
396396
.elementToAttribute( {
397397
view,
398398
model,
399-
converterPriority: definition.priority
399+
converterPriority: definition.converterPriority
400400
} );
401401
}
402402
}

tests/conversion/conversion.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,24 @@ describe( 'Conversion', () => {
133133
test( '<p>Foo</p>', '<paragraph>Foo</paragraph>' );
134134
} );
135135

136-
it( 'config.converterPriority is defined', () => {
136+
it( 'config.converterPriority is defined (override downcast)', () => {
137137
conversion.elementToElement( { model: 'paragraph', view: 'p' } );
138138
conversion.elementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
139139

140140
test( '<div>Foo</div>', '<paragraph>Foo</paragraph>' );
141141
test( '<p>Foo</p>', '<paragraph>Foo</paragraph>', '<div>Foo</div>' );
142142
} );
143143

144+
it( 'config.converterPriority is defined (override upcast)', () => {
145+
schema.register( 'foo', {
146+
inheritAllFrom: '$block'
147+
} );
148+
conversion.elementToElement( { model: 'paragraph', view: 'p' } );
149+
conversion.elementToElement( { model: 'foo', view: 'p', converterPriority: 'high' } );
150+
151+
test( '<p>Foo</p>', '<foo>Foo</foo>', '<p>Foo</p>' );
152+
} );
153+
144154
it( 'config.view is an object', () => {
145155
schema.register( 'fancyParagraph', {
146156
inheritAllFrom: 'paragraph'
@@ -232,14 +242,28 @@ describe( 'Conversion', () => {
232242
test( '<p><strong>Foo</strong> bar</p>', '<paragraph><$text bold="true">Foo</$text> bar</paragraph>' );
233243
} );
234244

235-
it( 'config.converterPriority is defined', () => {
245+
it( 'config.converterPriority is defined (override downcast)', () => {
236246
conversion.attributeToElement( { model: 'bold', view: 'strong' } );
237247
conversion.attributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
238248

239249
test( '<p><b>Foo</b></p>', '<paragraph><$text bold="true">Foo</$text></paragraph>' );
240250
test( '<p><strong>Foo</strong></p>', '<paragraph><$text bold="true">Foo</$text></paragraph>', '<p><b>Foo</b></p>' );
241251
} );
242252

253+
it( 'config.converterPriority is defined (override upcast)', () => {
254+
schema.extend( '$text', {
255+
allowAttributes: [ 'foo' ]
256+
} );
257+
conversion.attributeToElement( { model: 'bold', view: 'strong' } );
258+
conversion.attributeToElement( { model: 'foo', view: 'strong', converterPriority: 'high' } );
259+
260+
test(
261+
'<p><strong>Foo</strong></p>',
262+
'<paragraph><$text foo="true">Foo</$text></paragraph>',
263+
'<p><strong>Foo</strong></p>'
264+
);
265+
} );
266+
243267
it( 'config.view is an object', () => {
244268
conversion.attributeToElement( {
245269
model: 'bold',
@@ -634,6 +658,17 @@ describe( 'Conversion', () => {
634658
'<div border="border"><div shade="shade"></div></div>'
635659
);
636660
} );
661+
662+
it( 'config.converterPriority is defined (override downcast)', () => {
663+
schema.extend( 'image', {
664+
allowAttributes: [ 'foo' ]
665+
} );
666+
667+
conversion.attributeToAttribute( { model: 'foo', view: 'foo' } );
668+
conversion.attributeToAttribute( { model: 'foo', view: 'foofoo', converterPriority: 'high' } );
669+
670+
test( '<img foo="foo"></img>', '<image foo="foo"></image>', '<img foofoo="foo"></img>' );
671+
} );
637672
} );
638673

639674
function test( input, expectedModel, expectedView = null ) {

0 commit comments

Comments
 (0)