Coder Social home page Coder Social logo

is-dom's People

Contributors

mightyiam avatar peterhass avatar stevenvachon avatar tehshrike avatar timoxley avatar wtgtybhertgeghgtwtg avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

is-dom's Issues

New Version Breaks Electron (possibly non-browser NodeJS as well)

I was using "is-dom" indirectly via the "console-redirect" module from my electron-main.js. This was working forever until this last week when electron got an error about "window" not being defined during startup.

I had to change my package.json to explicitly require version 1.0.9 to avoid the problem.

Copyright information.

The license does not have the copyright information and I was not able to find the author information anywhere. Could you please include it? Thanks.

ProcessingInstruction Node fails check

I have a ProcessingInstruction Node that gets passed to this library to check if it's a Node. However, this specific type of node is returning false - I believe it should return true.

Here's a representation of the Node I'm talking about (and MDN docs here):

ProcessingInstruction {ownerDocument: Document, target: "xml", tagName: "xml", data: "version="1.0" encoding="UTF-8"", nodeValue: "version="1.0" encoding="UTF-8"", …}
  columnNumber: 1,
  data: "version="1.0" encoding="UTF-8"",
  lineNumber: 1,
  nextSibling: Text {ownerDocument: Document, data: "", nodeValue: "", length: 1, 
  previousSibling: ProcessingInstruction, …},
  nodeValue: "version="1.0" encoding="UTF-8"",
  ownerDocument: Document {implementation: DOMImplementation, childNodes: NodeList, doctype: null, documentURI: undefined, firstChild: ProcessingInstruction, …},
  parentNode: Document {implementation: DOMImplementation, childNodes: NodeList, doctype: null, documentURI: undefined, firstChild: ProcessingInstruction, …},
  previousSibling : null,
  tagName: "xml",
  target: "xml",
  textContent: (...),
  __proto__:
    nodeType: 7,
    constructor: ƒ ProcessingInstruction(),
    textContent: (...),

Note that this type of Node has a nodeType, but not a nodeName. The actual XML would look something like this:

<?xml version="1.0" encoding="UTF-8"?>               // <-- This is the ProcessingInstruction

It fails because these types of Nodes have a nodeType property, but not a nodeName property:

function isNode (val) {
  return (!val || typeof val !== 'object')
    ? false
    // This check fails because `typeof window.Node === "function"`
    : (typeof window === 'object' && typeof window.Node === 'object')
      // Branch not taken, but would return true
      ? (val instanceof window.Node)

      // **HERE**: `nodeName` does not exist on ProcessingInstruction nodes
      : (typeof val.nodeType === 'number') &&
        (typeof val.nodeName === 'string')
}

Do you agree this should be returning True on these types of nodes? I'd be happy to submit a PR with a fix, just not sure of the best way to go about.

One options: the typeof window === 'object' && typeof window.Node === 'object' could have one more case to check || typeof window.Now === 'function'. This would return true, and val instanceof window.Node would return true as well.

Let me know what you think!

Cross-realm support

Because you use instance of Node, nodes from other documents will return false.

Version 1.1.0 breaks support for IE10/11

I am using is-dom through embed-js. I was wondering why it started to throw weird errors in IE and started digging deeper ...

Yarn silently updated my projects is-dom package from 1.0.9 to 1.1.0.

Following line causes the problem in IE:

if (!isObject(val) || !isWindow(window) || typeof window.Node !== `function`) {

typeof window.Node !== 'function' always returns true in IE (window.Node is of type 'object')

My temporary workaround is to pin is-dom version to 1.0.9.

{
  "name": "test",
  "version": "0.0.0",
  "dependencies": {
    "embed-js": "^5.0.3",
    "embed-plugin-noembed": "^5.0.3",
  },
  "resolutions": {
    "is-dom": "1.0.9"
  },
  "module": "src/main.js"
}

Utilities library?

Would you be open to the idea of converting this into a multi-function library, similar to date-fns?:

import {
  isDetachedDOMNode,
  isDocumentDOMElement,
  isDOMElement,
  isDOMNode,
  isVoidDOMElement
} from 'is-dom';

I have these published separately already, but the use of many of them bloats a project's package.json file. I'd like to move them to this project and unpublish them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.