Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dens

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dens

dens, A DOM utility library that uses native methods and returns native HTMLElement. ================

  • 1.1.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

dens, A DOM utility library that uses native methods and returns native HTMLElement.

build into es5, for uglify does not support es6. (used in create-react-app)

Idea: Native APIs are first-class citizen, always return native HTMLElement.

USAGE

import {den, dens} from "dens"


- node is element or text node
- element is element
- text is text node

if not defined $ and $$, it will define
  window.$ = function(selector) { return typeof selector === "string" ? document.querySelector(selector) : selector || null }
  window.$$ = function(selector) { return [].slice.call(document.querySelectorAll(selector)) }

den("#parent").insertAfter(node, $("#child-a"))
[].slice.call(x.childNodes)


dens.closest("#hello")

API

den(selector) -> <#Den>

- closest(selectorString) -> HTMLElement
- isAncestor(ancestorNode)
- insertAfter(newNode, referenceNode)
- remove()

###########
# Class methods
###########

- den.isNode(obj) .. isElement isText isDocument isWindow
- den.isIE(maxVersion) .. isIOS isMac
- den.createElement(htmlText) -> HTMLElement

Install

$ npm install denjs --save
$ boewr install denjs --save

TODO

from medium-editor selection.js

getSelectedElements: function (doc) {
rangeSelectsSingleNode: function (range) {
getSelectedParentElement: function (range) {
getCaretOffsets: function getCaretOffsets(element, range) {
getSelectionHtml: function getSelectionHtml(doc) {
importSelection: function (selectionState, root, doc, favorLaterSelectionAnchor) {
exportSelection: function (root, doc) {

from quill lib/dom.js

...

FAQs

Package last updated on 10 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc