Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
41
Frontend-Learner/node_modules/svgo/plugins/removeDimensions.js
generated
vendored
Normal file
41
Frontend-Learner/node_modules/svgo/plugins/removeDimensions.js
generated
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
export const name = 'removeDimensions';
|
||||
export const description =
|
||||
'removes width and height in presence of viewBox (opposite to removeViewBox)';
|
||||
|
||||
/**
|
||||
* Remove width/height attributes and add the viewBox attribute if it's missing
|
||||
*
|
||||
* @example
|
||||
* <svg width="100" height="50" />
|
||||
* ↓
|
||||
* <svg viewBox="0 0 100 50" />
|
||||
*
|
||||
* @author Benny Schudel
|
||||
*
|
||||
* @type {import('../lib/types.js').Plugin}
|
||||
*/
|
||||
export const fn = () => {
|
||||
return {
|
||||
element: {
|
||||
enter: (node) => {
|
||||
if (node.name === 'svg') {
|
||||
if (node.attributes.viewBox != null) {
|
||||
delete node.attributes.width;
|
||||
delete node.attributes.height;
|
||||
} else if (
|
||||
node.attributes.width != null &&
|
||||
node.attributes.height != null &&
|
||||
Number.isNaN(Number(node.attributes.width)) === false &&
|
||||
Number.isNaN(Number(node.attributes.height)) === false
|
||||
) {
|
||||
const width = Number(node.attributes.width);
|
||||
const height = Number(node.attributes.height);
|
||||
node.attributes.viewBox = `0 0 ${width} ${height}`;
|
||||
delete node.attributes.width;
|
||||
delete node.attributes.height;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue