Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenvachon committed Jun 27, 2019
1 parent 8d34601 commit 2526343
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 62 deletions.
67 changes: 7 additions & 60 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,8 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
coverage/
index-es5.js
index-es5.js.map
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
.nyc_output/
package-lock.json
temp.js
temp.js.map
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- 10
- 12
- node
script: npm run ci
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,46 @@
# is-dom-orphan
Determine whether a node exists within the DOM tree.
# is-dom-detached [![NPM Version][npm-image]][npm-url] ![File Size][filesize-image] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Monitor][greenkeeper-image]][greenkeeper-url]

> Determine if a [`Node`](https://mdn.io/Node) does *not* exist within a DOM tree.

## Installation

[Node.js](http://nodejs.org) `>= 10` is required. To install, type this at the command line:
```shell
npm install is-dom-detached
```


## Importing

ES Module:
```js
import isDetachedNode from 'is-dom-detached';
```

CommonJS Module:
```js
const isDetachedNode = require('is-dom-detached');
```


## Usage

```js
const div = document.createElement('div');
isDetachedNode(div); //-> true

document.body.appendChild(div);
isDetachedNode(div); //-> false
````


[npm-image]: https://img.shields.io/npm/v/is-dom-detached.svg
[npm-url]: https://npmjs.com/package/is-dom-detached
[filesize-image]: https://img.shields.io/badge/size-490B%20gzipped-blue.svg
[travis-image]: https://img.shields.io/travis/stevenvachon/is-dom-detached.svg
[travis-url]: https://travis-ci.org/stevenvachon/is-dom-detached
[coveralls-image]: https://img.shields.io/coveralls/stevenvachon/is-dom-detached.svg
[coveralls-url]: https://coveralls.io/github/stevenvachon/is-dom-detached
[greenkeeper-image]: https://badges.greenkeeper.io/stevenvachon/is-dom-detached.svg
[greenkeeper-url]: https://greenkeeper.io/
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import isDOMDocument from "is-dom-document";
import isDOMNode from "is-dom";
import isWindow from "is-window";



export default node =>
{
if (!isDOMNode(node))
{
return false;
}
else if (isDOMDocument(node))
{
return !isWindow(node.defaultView);
}
else
{
return !node.ownerDocument.documentElement.contains(node);
}
};
75 changes: 75 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "is-dom-detached",
"description": "Determine if a Node does not exist within a DOM tree.",
"version": "2.0.0",
"license": "MIT",
"author": "Steven Vachon <contact@svachon.com> (https://svachon.com)",
"repository": "github:stevenvachon/is-dom-orphan",
"main": "index-es5.js",
"dependencies": {
"is-dom": "^1.1.0",
"is-dom-document": "^1.0.0",
"is-window": "^1.0.2"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-optional-chaining": "^7.2.0",
"@babel/preset-env": "^7.4.5",
"babel-plugin-add-module-exports": "^1.0.2",
"chai": "^4.2.0",
"coveralls": "^3.0.4",
"gzip-size-cli": "^3.0.0",
"mocha": "^6.1.4",
"npm-watch": "~0.6.0",
"nyc": "^14.1.1",
"parcel": "^1.12.3",
"puppeteer": "^1.18.1",
"puppeteer-to-istanbul": "^1.2.2",
"rimraf": "^2.6.3"
},
"engines": {
"node": ">= 10"
},
"scripts": {
"build": "npm run build-release && npm run build-size && npm run build-test",
"build-release": "babel index.js --out-file=index-es5.js --plugins=@babel/plugin-proposal-optional-chaining,add-module-exports --presets=@babel/env --source-maps",
"build-size": "parcel build index-es5.js --experimental-scope-hoisting --global=isDetachedNode --log-level=1 --no-cache --out-dir='.' --out-file=temp.js --public-url='.' && gzip-size temp.js && rimraf temp.js",
"build-test": "parcel build index-es5.js --global=isDetachedNode --log-level=1 --no-cache --out-dir='.' --out-file=temp.js --public-url='.'",
"build:watch": "npm-watch build",
"ci": "npm run test && nyc report --reporter=text-lcov | coveralls",
"posttest": "nyc report --reporter=text-summary --reporter=html && rimraf temp.js temp.js.map",
"prepublishOnly": "npm test",
"pretest": "npm run build",
"test": "nyc --silent mocha test.js --bail --check-leaks --timeout=5000",
"test:watch": "npm-watch test"
},
"watch": {
"build": {
"inherit": true,
"patterns": [
"index.js"
]
},
"test": {
"inherit": true,
"patterns": [
"index.js",
"test.js"
]
}
},
"files": [
"index.js",
"index-es5.js",
"index-es5.js.map"
],
"keywords": [
"detached",
"dom",
"isolated",
"node",
"orphan",
"stray"
]
}

0 comments on commit 2526343

Please sign in to comment.