ÿØÿà JFIF ÿá Exif MM * ÿÛ C
Server IP : 199.250.214.225 / Your IP : 18.118.163.169 Web Server : Apache System : Linux vps64074.inmotionhosting.com 3.10.0-1160.105.1.vz7.214.3 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : nicngo5 ( 1001) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/nicngo5/funds.upgrade.nicn.gov.ng/funds-upgraded/node_modules/svgo/lib/ |
Upload File : |
'use strict'; const { expect } = require('chai'); const { visit, detachNodeFromParent } = require('./xast.js'); const getAst = () => { const ast = { type: 'root', children: [ { type: 'element', name: 'g', attributes: {}, children: [ { type: 'element', name: 'rect', attributes: {}, children: [], }, { type: 'element', name: 'circle', attributes: {}, children: [], }, ], }, { type: 'element', name: 'ellipse', attributes: {}, children: [], }, ], }; ast.children[0].parentNode = ast; ast.children[0].children[0].parentNode = ast.children[0]; ast.children[0].children[1].parentNode = ast.children[0]; ast.children[1].parentNode = ast; return ast; }; describe('xast', () => { it('enter into nodes', () => { const root = getAst(); const entered = []; visit(root, { root: { enter: (node) => { entered.push(node.type); }, }, element: { enter: (node) => { entered.push(`${node.type}:${node.name}`); }, }, }); expect(entered).to.deep.equal([ 'root', 'element:g', 'element:rect', 'element:circle', 'element:ellipse', ]); }); it('exit from nodes', () => { const root = getAst(); const exited = []; visit(root, { root: { exit: (node) => { exited.push(node.type); }, }, element: { exit: (node) => { exited.push(`${node.type}:${node.name}`); }, }, }); expect(exited).to.deep.equal([ 'element:rect', 'element:circle', 'element:g', 'element:ellipse', 'root', ]); }); it('skip entering children if node is detached', () => { const root = getAst(); const entered = []; visit(root, { element: { enter: (node) => { entered.push(node.name); if (node.name === 'g') { detachNodeFromParent(node); } }, }, }); expect(entered).to.deep.equal(['g', 'ellipse']); }); });