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

dom-element-is-natively-editable

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-element-is-natively-editable - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

21

index.js

@@ -11,3 +11,3 @@ module.exports = function (element) {

case 'input':
return true
return isEditableInput(element)
case 'textarea':

@@ -40,1 +40,20 @@ return true

}
function isEditableInput (input) {
switch (input.type) {
case 'text':
return true
case 'email':
return true
case 'password':
return true
case 'search':
return true
case 'tel':
return true
case 'url':
return true
default:
return false
}
}

2

package.json
{
"name": "dom-element-is-natively-editable",
"version": "1.0.1",
"version": "1.0.2",
"description": "Returns true if the provided DOM element is supposed to be natively editable",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -83,12 +83,30 @@ /* eslint-env mocha */

context('provided an `input` element', () => {
it('sync returns true', (done) => {
jsdom.env('<input>input</input>', (err, {document}) => {
if (err) {
return
}
const element = document.querySelector('input')
isEditable(element).should.be.true
done()
// this list of types is kind of a guess based on:
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
;['text', 'email', 'password', 'search', 'tel', 'url'].forEach((type) => {
context(`that is of type \`${type}\``, () => {
it('sync returns true', (done) => {
jsdom.env(`<input type="${type}">${type} input</input>`, (err, {document}) => {
if (err) {
return
}
const element = document.querySelector('input')
isEditable(element).should.be.true
done()
})
})
})
})
context('that is not of an editable type (`radio`)', () => {
it('sync returns false', (done) => {
jsdom.env('<input type="radio">radio input</input>', (err, {document}) => {
if (err) {
return
}
const element = document.querySelector('input')
isEditable(element).should.be.false
done()
})
})
})
})

@@ -95,0 +113,0 @@ context('provided a `textarea` element', () => {

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