{"name":"validate-html-nesting","version":"1.0.2","description":"Validate parent-child nesting for HTML elements","main":"src/index.js","types":"./src/types.d.ts","scripts":{"test":"jest"},"keywords":["html validator","dom validator"],"author":{"name":"Manan Tank"},"repository":{"type":"git","url":"git+https://github.com/MananTank/validate-html-nesting.git"},"license":"ISC","devDependencies":{"@types/jest":"^27.5.1","jest":"^28.1.0"},"gitHead":"734ecfc8d8d22cdeb343a0ac92dc993ef97ef018","bugs":{"url":"https://github.com/MananTank/validate-html-nesting/issues"},"homepage":"https://github.com/MananTank/validate-html-nesting#readme","_id":"validate-html-nesting@1.0.2","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-0eUJ1TJ8Pr5+/4E004blNnR5wqlnVYn5vJ7u0avl29kuU6KS2HTngJ0WpdyEEqeArHoizLu0iUA5zyJt/jB1RA==","shasum":"a9b602f5fc2deb7eab7fe3ba30e804dcdb2aaa2b","tarball":"http://registry-npm.ywwl.com/validate-html-nesting/download/validate-html-nesting-1.0.2.tgz","fileCount":7,"unpackedSize":11542,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCHYlKkJLv25Cz2lVjQ8LZEMs2imOeiZc6lzF0nh1r1GAIgHh1SnwVcTgQH5uABl8YBpJ2+zMvsSWyTxKUTNyF2opY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJif9OAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqtvQ//fMg/2+p6pFq6C02OweHYzv/nDivSU9ohac2SJimRHq+V3YKQ\r\natmTt4+gpQN+2dD4pOR/UbrYEOR8qLL/102oES5DH1AIe4LenPWWV3aKixoo\r\nu3k9kvd7EyK0oqHOYpPkz5jAZUkoDYDEnkyALbybdobPm2bwXvsU3Q/CLybP\r\nbBWUijwTMiA+8uQS3Jao8qsF0lXwCNBHgHH3qjBFHOxib6pl04ELGTHUWkQh\r\nJzS9j3lxFq0EECRZqSyk2p/dNcbOPIUGwEf0+EglD0vy+yEjq9QRPC23tgYW\r\ngZRT0qoGSPjCBRRODLSXWsgjt5m3Qduy+zcfVBPvxYamT2yncCQFBfwoH5B9\r\ntG8beMhZnVOoU87kl7L3c/IP2GpPGTrVsEmj1r6YDuyr6T/egYz7tIpVOJuj\r\nR74V79sFo3GuyBU4IV0xPbEbFRFXgFVmkV/fQ67rl8K/kOQNScQxd7LXzz1M\r\nE0Ab7LnSZUa1SzFGWuLHwnMB6zJRMvpSYbMwUkYdTA3VyDv0M2N+mJ3jvUb5\r\nry8emVx+lETmYACrdi2kUR2XJVgLrFiEUTKIJ/HYpJXlqjgPcd5YvyxZ+VY7\r\nMrfch9LjVZtFKooxq52/JftBO0LaAFQEjr5PAcBbgYL6JJ9YCyEHgLIXeybc\r\nOPFnleoA9g5WxxulSJNLmfyRVpNFa9PhfMY=\r\n=ey2G\r\n-----END PGP SIGNATURE-----\r\n","size":3363,"noattachment":false,"key":"/validate-html-nesting/-/validate-html-nesting-1.0.2.tgz"},"_npmUser":{"name":"manantank","email":"manantankm@gmail.com"},"directories":{},"maintainers":[{"name":"manantank","email":"manantankm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/validate-html-nesting_1.0.2_1652544384402_0.2593276353290821"},"_hasShrinkwrap":false,"readme":"# validate-html-nesting\n\nA parent-child nesting validation library for HTML\n\nThis is not a full-blown HTML spec validation (intentionally). The parent-child nesting is considered valid if the Browser does not modify it, regardless of whether or not the HTML spec considers it valid or invalid. So, the library is purely for detecting the kind of element nesting which result in altered DOM.\n\n### Example\n\n```html\n<p>\n  hello\n  <hr/>\n</p>\n```\n\nThe Browser modifies the above-shown structure to the below-shown structure, which is why the library considers the `p > hr` nesting invalid.\n\n```html\n<p>hello</p>\n<hr />\n<p></p>\n```\n\nAnd though `<h1> <div> hi </div> </h1>` markup is technically invalid as per HTML spec, it's still considered valid because the browser does not modify it, so `h1 > div` nesting is considered valid by the library.\n\n<br/>\n\n## Install\n\n```bash\nnpm i validate-html-nesting\n```\n\n<br/>\n\n## API\n\n```javascript\nisValidHTMLNesting(parentTag: string, childTag: string) : boolean\n```\n\n<br />\n\n## Usage Example\n\n```javascript\nimport { isValidHTMLNesting } from 'validate-html-nesting';\n\nisValidHTMLNesting('a', 'a'); // false\n// because <a> can not be child of <a>\n\nisValidHTMLNesting('p', 'hr'); // false\n// because <hr> can not be child of <p>\n\nisValidHTMLNesting('div', 'a'); // true\n// because <a> can be child of <div>\n```\n\n<br/>\n\n## See also\n\n- [eslint-plugin-validate-jsx-nesting](https://github.com/MananTank/eslint-plugin-validate-jsx-nesting) - ESLint plugin for JSX nesting validation\n- [babel-plugin-validate-jsx-nesting](https://github.com/MananTank/validate-jsx-nesting) - Compile time JSX nesting validation\n\n<br/>\n\n## Who is this library for?\n\nThis library is mostly useful for UI framework authors who need a way to make sure that the DOM structure rendered by the browser matches the authored markup so that there are no unexpected behaviors\n\n<br/>\n\n## Test Suite\n\nRefer to [validation.test.js](/tests/validation.test.js) to see the full test suite\n\n<br/>\n\n## Contributing\n\nPRs are welcome.\nCreate an issue if you found a bug.\n","publish_time":1652544384555,"_cnpm_publish_time":1652544384555,"dist-tags":{"latest":"1.2.4"}}