diff --git a/lib/CSSStyleDeclaration.test.js b/lib/CSSStyleDeclaration.test.js index 363c2ffc..b7ded3af 100644 --- a/lib/CSSStyleDeclaration.test.js +++ b/lib/CSSStyleDeclaration.test.js @@ -102,6 +102,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'); diff --git a/lib/properties/borderWidth.js b/lib/properties/borderWidth.js index 88b2aa82..c2c7c362 100644 --- a/lib/properties/borderWidth.js +++ b/lib/properties/borderWidth.js @@ -32,6 +32,7 @@ var parser = function(v) { } return undefined; }; +module.exports.parse = parser; module.exports.definition = { set: implicitSetter('border', 'width', isValid, parser), diff --git a/lib/properties/outline.js b/lib/properties/outline.js new file mode 100644 index 00000000..e4dcd472 --- /dev/null +++ b/lib/properties/outline.js @@ -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, +}; diff --git a/lib/properties/outlineColor.js b/lib/properties/outlineColor.js index fc8093df..a01dac65 100644 --- a/lib/properties/outlineColor.js +++ b/lib/properties/outlineColor.js @@ -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'); diff --git a/lib/properties/outlineStyle.js b/lib/properties/outlineStyle.js new file mode 100644 index 00000000..e2ed4942 --- /dev/null +++ b/lib/properties/outlineStyle.js @@ -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, +}; diff --git a/lib/properties/outlineWidth.js b/lib/properties/outlineWidth.js new file mode 100644 index 00000000..adb3a8d2 --- /dev/null +++ b/lib/properties/outlineWidth.js @@ -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, +};