Skip to content

fix: handle outline style/width #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/CSSStyleDeclaration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ describe('CSSStyleDeclaration', () => {
expect(style.borderTopWidth).toEqual('0px');
expect(style.borderLeftStyle).toEqual('solid');
expect(style.borderBottomColor).toEqual('black');
style.outline = 'black solid 0';
expect(style.outlineWidth).toEqual('0px');
expect(style.outlineStyle).toEqual('solid');
expect(style.outlineColor).toEqual('black');
style.font = '12em monospace';
expect(style.fontSize).toEqual('12em');
expect(style.fontFamily).toEqual('monospace');
Expand Down
1 change: 1 addition & 0 deletions lib/properties/borderWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var parser = function(v) {
}
return undefined;
};
module.exports.parse = parser;

module.exports.definition = {
set: implicitSetter('border', 'width', isValid, parser),
Expand Down
17 changes: 17 additions & 0 deletions lib/properties/outline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

var shorthandSetter = require('../parsers').shorthandSetter;
var shorthandGetter = require('../parsers').shorthandGetter;

var shorthand_for = {
'outline-color': require('./outlineColor'),
'outline-style': require('./outlineStyle'),
'outline-width': require('./outlineWidth'),
};

module.exports.definition = {
set: shorthandSetter('outline', shorthand_for),
get: shorthandGetter('outline', shorthand_for),
enumerable: true,
configurable: true,
};
6 changes: 4 additions & 2 deletions lib/properties/outlineColor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

var parseColor = require('../parsers').parseColor;
var isValid = (module.exports.isValid = require('./borderColor').isValid);

module.exports.definition = {
set: function(v) {
this._setProperty('outline-color', parseColor(v));
if (isValid(v)) {
this._setProperty('outline-color', v);
}
},
get: function() {
return this.getPropertyValue('outline-color');
Expand Down
20 changes: 20 additions & 0 deletions lib/properties/outlineStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

var isValid = (module.exports.isValid = require('./borderStyle').isValid);

module.exports.definition = {
set: function(v) {
if (isValid(v)) {
if (v.toLowerCase() === 'none') {
v = '';
this.removeProperty('outline-style');
}
this._setProperty('outline-style', v);
}
},
get: function() {
return this.getPropertyValue('outline-style');
},
enumerable: true,
configurable: true,
};
18 changes: 18 additions & 0 deletions lib/properties/outlineWidth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

var borderWidth = require('./borderWidth');
var isValid = (module.exports.isValid = borderWidth.isValid);
var parse = borderWidth.parse;

module.exports.definition = {
set: function(v) {
if (isValid(v)) {
this._setProperty('outline-width', parse(v));
}
},
get: function() {
return this.getPropertyValue('outline-width');
},
enumerable: true,
configurable: true,
};