Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevenvachon/assign-dom-doctype
Insert, replace or remove a DocumentType node within a Document.
https://github.com/stevenvachon/assign-dom-doctype
doctype document document-type dom node
Last synced: about 2 months ago
JSON representation
Insert, replace or remove a DocumentType node within a Document.
- Host: GitHub
- URL: https://github.com/stevenvachon/assign-dom-doctype
- Owner: stevenvachon
- License: mit
- Created: 2019-11-11T21:44:58.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-22T23:36:44.000Z (about 5 years ago)
- Last Synced: 2024-10-06T04:23:48.431Z (4 months ago)
- Topics: doctype, document, document-type, dom, node
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assign-dom-doctype [![NPM Version][npm-image]][npm-url] ![File Size][filesize-image] ![Build Status][ci-image] [![Coverage Status][coveralls-image]][coveralls-url]
> Insert, replace or remove a [`DocumentType` node](https://mdn.io/DocumentType) within a [`Document`](https://mdn.io/Document).
## Installation
[Node.js](http://nodejs.org) `>= 10` is required. To install, type this at the command line:
```shell
npm install assign-dom-doctype
```## Importing
ES Module:
```js
import assignDoctype from 'assign-dom-doctype';
```CommonJS Module:
```js
const assignDoctype = require('assign-dom-doctype');
```## Usage
Insert or replace:
```js
const newDoctype = document.implementation.createDocumentType('qualifiedNameStr', 'publicId', 'systemId');assignDoctype(newDoctype, document);
````Remove:
```js
assignDoctype(null, document);
```The `Document`'s previous [`doctype`](https://mdn.io/Document/doctype) value will be returned.
## Compatibility
Depending on your target browsers, you may need polyfills/shims for the following:
* [`Node::before`](https://mdn.io/Node/before)
* [`Node::remove`](https://mdn.io/Node/remove)
* [`Node::replaceWith`](https://mdn.io/Node/replaceWith)[npm-image]: https://img.shields.io/npm/v/assign-dom-doctype.svg
[npm-url]: https://npmjs.com/package/assign-dom-doctype
[filesize-image]: https://img.shields.io/badge/size-540B%20gzipped-blue.svg
[ci-image]: https://github.com/stevenvachon/assign-dom-doctype/workflows/tests/badge.svg
[coveralls-image]: https://img.shields.io/coveralls/stevenvachon/assign-dom-doctype.svg
[coveralls-url]: https://coveralls.io/github/stevenvachon/assign-dom-doctype