UNPKG

708 BJavaScriptView Raw
1'use strict';
2
3exports.type = 'perItem';
4
5exports.active = false;
6
7exports.description = 'removes width and height in presence of viewBox (opposite to removeViewBox, disable it first)';
8
9/**
10 * Remove width/height attributes when a viewBox attribute is present.
11 *
12 * @example
13 * <svg width="100" height="50" viewBox="0 0 100 50">
14 * ↓
15 * <svg viewBox="0 0 100 50">
16 *
17 * @param {Object} item current iteration item
18 * @return {Boolean} if true, with and height will be filtered out
19 *
20 * @author Benny Schudel
21 */
22exports.fn = function(item) {
23
24 if (
25 item.isElem('svg') &&
26 item.hasAttr('viewBox')
27 ) {
28 item.removeAttr('width');
29 item.removeAttr('height');
30 }
31
32};