diff --git a/lib/checks/shared/avoid-inline-spacing-evaluate.js b/lib/checks/shared/avoid-inline-spacing-evaluate.js index 97a86103ce..c0b7c6413d 100644 --- a/lib/checks/shared/avoid-inline-spacing-evaluate.js +++ b/lib/checks/shared/avoid-inline-spacing-evaluate.js @@ -1,11 +1,5 @@ -function avoidInlineSpacingEvaluate(node) { - const inlineSpacingCssProperties = [ - 'line-height', - 'letter-spacing', - 'word-spacing' - ]; - - const overriddenProperties = inlineSpacingCssProperties.filter(property => { +function avoidInlineSpacingEvaluate(node, options) { + const overriddenProperties = options.cssProperties.filter(property => { if (node.style.getPropertyPriority(property) === `important`) { return property; } diff --git a/lib/checks/shared/avoid-inline-spacing.json b/lib/checks/shared/avoid-inline-spacing.json index d7d4f79198..be1f3e2d9f 100644 --- a/lib/checks/shared/avoid-inline-spacing.json +++ b/lib/checks/shared/avoid-inline-spacing.json @@ -1,6 +1,9 @@ { "id": "avoid-inline-spacing", "evaluate": "avoid-inline-spacing-evaluate", + "options": { + "cssProperties": ["line-height", "letter-spacing", "word-spacing"] + }, "metadata": { "impact": "serious", "messages": { diff --git a/test/checks/shared/avoid-inline-spacing.js b/test/checks/shared/avoid-inline-spacing.js index ff500bba19..dd626a1194 100644 --- a/test/checks/shared/avoid-inline-spacing.js +++ b/test/checks/shared/avoid-inline-spacing.js @@ -3,7 +3,7 @@ describe('avoid-inline-spacing tests', function() { var fixture = document.getElementById('fixture'); var queryFixture = axe.testUtils.queryFixture; - var check = checks['avoid-inline-spacing']; + var checkEvaluate = axe.testUtils.getCheckEvaluate('avoid-inline-spacing'); var checkContext = axe.testUtils.MockCheckContext(); afterEach(function() { @@ -15,7 +15,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -24,7 +24,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -33,7 +33,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -42,7 +42,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -51,7 +51,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -60,7 +60,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -69,7 +69,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isTrue(actual); assert.isNull(checkContext._data); }); @@ -78,7 +78,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isFalse(actual); assert.deepEqual(checkContext._data, ['line-height']); }); @@ -87,7 +87,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isFalse(actual); assert.deepEqual(checkContext._data, ['letter-spacing']); }); @@ -96,7 +96,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isFalse(actual); assert.deepEqual(checkContext._data, ['word-spacing']); }); @@ -105,7 +105,7 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isFalse(actual); assert.deepEqual(checkContext._data, ['letter-spacing']); }); @@ -114,8 +114,19 @@ describe('avoid-inline-spacing tests', function() { var vNode = queryFixture( '

The quick brown fox jumped over the lazy dog

' ); - var actual = check.evaluate.call(checkContext, vNode.actualNode); + var actual = checkEvaluate.call(checkContext, vNode.actualNode); assert.isFalse(actual); assert.deepEqual(checkContext._data, ['line-height', 'letter-spacing']); }); + + it('supports options.cssProperties', function() { + var vNode = queryFixture( + '

The quick brown fox jumped over the lazy dog

' + ); + var actual = checkEvaluate.call(checkContext, vNode.actualNode, { + cssProperties: ['font-size'] + }); + assert.isFalse(actual); + assert.deepEqual(checkContext._data, ['font-size']); + }); });