Skip to content

Commit

Permalink
Made dimension attributes (width & height) optional (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkphl committed Jan 28, 2015
1 parent 1de2822 commit 4e486dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ Property | Type | Default | Description
`dimension.maxWidth` | Integer | `2000` | Maximum shape width in pixels |
`dimension.maxHeight` | Integer | `2000` | Maximum shape height in pixels |
`dimension.precision` | Integer | `2` | Precision (number of decimal places) for dimension calculations |
`dimension.attributes` | Boolean | `false` | If truthy, `width` and `height` attributes will be set on the shapes inside the sprite (where applicable). |
`spacing.padding` | Integer/Array | `0` | Padding around shape. May be a single pixel value (which is then applied to all four edges) or an Array of Integers with a length between 1 and 4 (same syntax as for CSS padding) |
`spacing.box` | String | `"content"` | Box sizing strategy, similar to CSS. When *content* is given, the `spacing.padding` will get applied outside the shape, thus effectively increasing the shapes bounding box. When *padding*, the content plus the given `spacing.padding` will stay within the given dimension contraints. |
`meta` | String | | Path to a [YAML](http://yaml.org/) file with [meta data to be injected](#a1-meta-data-injection) into the SVG shapes. |
Expand Down Expand Up @@ -999,7 +1000,8 @@ Release history
---------------

#### master (will become v1.0.13)
# Fixed windows path separator bug ([gulp-svg-sprite #6](https://github.com/jkphl/gulp-svg-sprite/issues/6))
* Fixed windows path separator bug ([gulp-svg-sprite #6](https://github.com/jkphl/gulp-svg-sprite/issues/6))
* Made dimension attributes (width & height) optional ([#45](https://github.com/jkphl/svg-sprite/issues/45))

#### v1.0.12 Feature release (2015-01-27)
* Added dimension CSS output for non-CSS sprites ([#45](https://github.com/jkphl/svg-sprite/issues/45))
Expand Down
14 changes: 13 additions & 1 deletion lib/svg-sprite/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ defaultConfig = {
*
* @type {Number}
*/
precision : 2
precision : 2,
/**
* Add dimension attributes
*
* @type {Boolean}
*/
attributes : false
},
/**
* Spacing related options
Expand Down Expand Up @@ -250,6 +256,12 @@ SVGShape.prototype.getSVG = function(inline, transform) {
// Else
} else {
svg = this.dom.documentElement.cloneNode(true);

// Remove dimension attributes if not requested
if (!this.config.dimension.attributes) {
svg.removeAttribute('width');
svg.removeAttribute('height');
}
}

// Call the final transformer (if available)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svg-sprite",
"version": "1.0.12",
"version": "1.0.13",
"author": {
"name": "Joschi Kuphal",
"email": "joschi@kuphal.net",
Expand Down

0 comments on commit 4e486dd

Please sign in to comment.