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

@wordpress/dom

Package Overview
Dependencies
Maintainers
14
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/dom - npm Package Compare versions

Comparing version 2.9.0 to 2.10.0

23

build-module/dom.js

@@ -451,4 +451,3 @@ /**

/**
* Check wether the current document has a selection.
* This checks both for focus in an input field and general text selection.
* Check whether the current document has selected text.
*

@@ -458,11 +457,3 @@ * @return {boolean} True if there is selection, false if not.

export function documentHasSelection() {
if (isTextField(document.activeElement)) {
return true;
}
if (isNumberInput(document.activeElement)) {
return true;
}
export function documentHasTextSelection() {
var selection = window.getSelection();

@@ -473,2 +464,12 @@ var range = selection.rangeCount ? selection.getRangeAt(0) : null;

/**
* Check whether the current document has a selection. This checks for both
* focus in an input field and general text selection.
*
* @return {boolean} True if there is selection, false if not.
*/
export function documentHasSelection() {
return isTextField(document.activeElement) || isNumberInput(document.activeElement) || documentHasTextSelection();
}
/**
* Check whether the contents of the element have been entirely selected.

@@ -475,0 +476,0 @@ * Returns true if there is no possibility of selection.

@@ -14,2 +14,3 @@ "use strict";

exports.isNumberInput = isNumberInput;
exports.documentHasTextSelection = documentHasTextSelection;
exports.documentHasSelection = documentHasSelection;

@@ -485,4 +486,3 @@ exports.isEntirelySelected = isEntirelySelected;

/**
* Check wether the current document has a selection.
* This checks both for focus in an input field and general text selection.
* Check whether the current document has selected text.
*

@@ -493,11 +493,3 @@ * @return {boolean} True if there is selection, false if not.

function documentHasSelection() {
if (isTextField(document.activeElement)) {
return true;
}
if (isNumberInput(document.activeElement)) {
return true;
}
function documentHasTextSelection() {
var selection = window.getSelection();

@@ -508,2 +500,13 @@ var range = selection.rangeCount ? selection.getRangeAt(0) : null;

/**
* Check whether the current document has a selection. This checks for both
* focus in an input field and general text selection.
*
* @return {boolean} True if there is selection, false if not.
*/
function documentHasSelection() {
return isTextField(document.activeElement) || isNumberInput(document.activeElement) || documentHasTextSelection();
}
/**
* Check whether the contents of the element have been entirely selected.

@@ -510,0 +513,0 @@ * Returns true if there is no possibility of selection.

@@ -0,1 +1,11 @@

<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/master/packages#maintaining-changelogs. -->
## Unreleased
## 2.10.0 (2020-05-28)
### New Feature
- Add `documentHasTextSelection` to inquire specifically about ranges of selected text, in addition to the existing `documentHasSelection`.
## 2.1.0 (2019-03-06)

@@ -2,0 +12,0 @@

{
"name": "@wordpress/dom",
"version": "2.9.0",
"version": "2.10.0",
"description": "DOM utilities module for WordPress.",

@@ -32,3 +32,3 @@ "author": "The WordPress Contributors",

},
"gitHead": "65dbf3a9503402ca3837090dc89d0207f7d96352"
"gitHead": "21b9900901963649e69faa6eff697a4105423aa8"
}

@@ -27,4 +27,4 @@ # DOM

Check wether the current document has a selection.
This checks both for focus in an input field and general text selection.
Check whether the current document has a selection. This checks for both
focus in an input field and general text selection.

@@ -35,2 +35,10 @@ _Returns_

<a name="documentHasTextSelection" href="#documentHasTextSelection">#</a> **documentHasTextSelection**
Check whether the current document has selected text.
_Returns_
- `boolean`: True if there is selection, false if not.
<a name="focus" href="#focus">#</a> **focus**

@@ -37,0 +45,0 @@

@@ -487,19 +487,9 @@ /**

/**
* Check wether the current document has a selection.
* This checks both for focus in an input field and general text selection.
* Check whether the current document has selected text.
*
* @return {boolean} True if there is selection, false if not.
*/
export function documentHasSelection() {
if ( isTextField( document.activeElement ) ) {
return true;
}
if ( isNumberInput( document.activeElement ) ) {
return true;
}
export function documentHasTextSelection() {
const selection = window.getSelection();
const range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;
return range && ! range.collapsed;

@@ -509,2 +499,16 @@ }

/**
* Check whether the current document has a selection. This checks for both
* focus in an input field and general text selection.
*
* @return {boolean} True if there is selection, false if not.
*/
export function documentHasSelection() {
return (
isTextField( document.activeElement ) ||
isNumberInput( document.activeElement ) ||
documentHasTextSelection()
);
}
/**
* Check whether the contents of the element have been entirely selected.

@@ -511,0 +515,0 @@ * Returns true if there is no possibility of selection.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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