Document application modes (development/debug/production) Add global file drop handler, order column normalization, SPA hash fix Serve CDN assets via /_vendor/ URLs instead of merging into bundles Add production minification with license preservation Improve JSON formatting for debugging and production optimization Add CDN asset caching with CSS URL inlining for production builds Add three-mode system (development, debug, production) Update Manifest CLAUDE.md to reflect helper class architecture Refactor Manifest.php into helper classes for better organization Pre-manifest-refactor checkpoint: Add app_mode documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
1.7 KiB
JavaScript
Executable File
68 lines
1.7 KiB
JavaScript
Executable File
import { elemsGroups } from './_collections.js';
|
|
import { detachNodeFromParent } from '../lib/xast.js';
|
|
import { collectStylesheet, computeStyle } from '../lib/style.js';
|
|
|
|
export const name = 'removeEmptyContainers';
|
|
export const description = 'removes empty container elements';
|
|
|
|
/**
|
|
* Remove empty containers.
|
|
*
|
|
* @see https://www.w3.org/TR/SVG11/intro.html#TermContainerElement
|
|
*
|
|
* @example
|
|
* <defs/>
|
|
*
|
|
* @example
|
|
* <g><marker><a/></marker></g>
|
|
*
|
|
* @author Kir Belevich
|
|
*
|
|
* @type {import('../lib/types.js').Plugin}
|
|
*/
|
|
export const fn = (root) => {
|
|
const stylesheet = collectStylesheet(root);
|
|
|
|
return {
|
|
element: {
|
|
exit: (node, parentNode) => {
|
|
// remove only empty non-svg containers
|
|
if (
|
|
node.name === 'svg' ||
|
|
!elemsGroups.container.has(node.name) ||
|
|
node.children.length !== 0
|
|
) {
|
|
return;
|
|
}
|
|
// empty patterns may contain reusable configuration
|
|
if (
|
|
node.name === 'pattern' &&
|
|
Object.keys(node.attributes).length !== 0
|
|
) {
|
|
return;
|
|
}
|
|
|
|
// empty <mask> hides masked element
|
|
if (node.name === 'mask' && node.attributes.id != null) {
|
|
return;
|
|
}
|
|
if (parentNode.type === 'element' && parentNode.name === 'switch') {
|
|
return;
|
|
}
|
|
|
|
// The <g> may not have content, but the filter may cause a rectangle
|
|
// to be created and filled with pattern.
|
|
if (
|
|
node.name === 'g' &&
|
|
(node.attributes.filter != null ||
|
|
computeStyle(stylesheet, node).filter)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
detachNodeFromParent(node, parentNode);
|
|
},
|
|
},
|
|
};
|
|
};
|