Skip to content

Commit

Permalink
[css] Incorrect "Property is ignored" warning when specifying width o…
Browse files Browse the repository at this point in the history
…n inline replaced elements Fixes microsoft/vscode#56907
  • Loading branch information
aeschli committed Sep 10, 2020
1 parent e527c66 commit 7162927
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
18 changes: 1 addition & 17 deletions src/services/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,24 +327,8 @@ export class LintVisitor implements nodes.IVisitor {
// Properties ignored due to display
/////////////////////////////////////////////////////////////

// With 'display: inline', the width, height, margin-top, margin-bottom, and float properties have no effect
let displayElems = this.fetchWithValue(propertyTable, 'display', 'inline');
if (displayElems.length > 0) {
for (const prop of ['width', 'height', 'margin-top', 'margin-bottom', 'float']) {
const elem = this.fetch(propertyTable, prop);
for (let index = 0; index < elem.length; index++) {
const node = elem[index].node;
const value = node.getValue();
if (prop === 'float' && (!value || value.matches('none'))) {
continue;
}
this.addEntry(node, Rules.PropertyIgnoredDueToDisplay, localize('rule.propertyIgnoredDueToDisplayInline', "Property is ignored due to the display. With 'display: inline', the width, height, margin-top, margin-bottom, and float properties have no effect."));
}
}
}

// With 'display: inline-block', 'float' has no effect
displayElems = this.fetchWithValue(propertyTable, 'display', 'inline-block');
let displayElems = this.fetchWithValue(propertyTable, 'display', 'inline-block');
if (displayElems.length > 0) {
const elem = this.fetch(propertyTable, 'float');
for (let index = 0; index < elem.length; index++) {
Expand Down
6 changes: 1 addition & 5 deletions src/test/css/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ suite('CSS - Lint', () => {
});

test('properies ignored due to inline ', function () {
assertRuleSet('selector { display: inline; height: 100px; }', Rules.PropertyIgnoredDueToDisplay);
assertRuleSet('selector { display: inline; width: 100px; }', Rules.PropertyIgnoredDueToDisplay);
assertRuleSet('selector { display: inline; margin-top: 1em; }', Rules.PropertyIgnoredDueToDisplay);
assertRuleSet('selector { display: inline; margin-bottom: 1em; }', Rules.PropertyIgnoredDueToDisplay);
assertRuleSet('selector { display: inline; float: right; }', Rules.PropertyIgnoredDueToDisplay, Rules.AvoidFloat);
assertRuleSet('selector { display: inline; float: right; }', Rules.AvoidFloat);
assertRuleSet('selector { display: inline; float: none; }', Rules.AvoidFloat);
assertRuleSet('selector { display: inline-block; float: right; }', Rules.PropertyIgnoredDueToDisplay, Rules.AvoidFloat);
assertRuleSet('selector { display: inline-block; float: none; }', Rules.AvoidFloat);
Expand Down

0 comments on commit 7162927

Please sign in to comment.