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

@wordpress/dom

Package Overview
Dependencies
Maintainers
21
Versions
192
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 3.1.1 to 3.1.2

31

build-module/dom/is-entirely-selected.js

@@ -52,7 +52,32 @@ /**

assertIsDefined(lastChild, 'lastChild');
const lastChildContentLength = lastChild.nodeType === lastChild.TEXT_NODE ?
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ?
/** @type {Text} */
lastChild.data.length : lastChild.childNodes.length;
return startContainer === element.firstChild && endContainer === element.lastChild && startOffset === 0 && endOffset === lastChildContentLength;
endContainer.data.length : endContainer.childNodes.length;
return isDeepChild(startContainer, element, 'firstChild') && isDeepChild(endContainer, element, 'lastChild') && startOffset === 0 && endOffset === endContainerContentLength;
}
/**
* Check whether the contents of the element have been entirely selected.
* Returns true if there is no possibility of selection.
*
* @param {HTMLElement|Node} query The element to check.
* @param {HTMLElement} container The container that we suspect "query" may be a first or last child of.
* @param {"firstChild"|"lastChild"} propName "firstChild" or "lastChild"
*
* @return {boolean} True if query is a deep first/last child of container, false otherwise.
*/
function isDeepChild(query, container, propName) {
/** @type {HTMLElement | ChildNode | null} */
let candidate = container;
do {
if (query === candidate) {
return true;
}
candidate = candidate[propName];
} while (candidate);
return false;
}
//# sourceMappingURL=is-entirely-selected.js.map

@@ -63,7 +63,33 @@ "use strict";

(0, _assertIsDefined.assertIsDefined)(lastChild, 'lastChild');
const lastChildContentLength = lastChild.nodeType === lastChild.TEXT_NODE ?
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ?
/** @type {Text} */
lastChild.data.length : lastChild.childNodes.length;
return startContainer === element.firstChild && endContainer === element.lastChild && startOffset === 0 && endOffset === lastChildContentLength;
endContainer.data.length : endContainer.childNodes.length;
return isDeepChild(startContainer, element, 'firstChild') && isDeepChild(endContainer, element, 'lastChild') && startOffset === 0 && endOffset === endContainerContentLength;
}
/**
* Check whether the contents of the element have been entirely selected.
* Returns true if there is no possibility of selection.
*
* @param {HTMLElement|Node} query The element to check.
* @param {HTMLElement} container The container that we suspect "query" may be a first or last child of.
* @param {"firstChild"|"lastChild"} propName "firstChild" or "lastChild"
*
* @return {boolean} True if query is a deep first/last child of container, false otherwise.
*/
function isDeepChild(query, container, propName) {
/** @type {HTMLElement | ChildNode | null} */
let candidate = container;
do {
if (query === candidate) {
return true;
}
candidate = candidate[propName];
} while (candidate);
return false;
}
//# sourceMappingURL=is-entirely-selected.js.map

4

package.json
{
"name": "@wordpress/dom",
"version": "3.1.1",
"version": "3.1.2",
"description": "DOM utilities module for WordPress.",

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

},
"gitHead": "954d6776be2ee80b5975e4ced6a3d481d8a89354"
"gitHead": "a39d5605fcea63a9e02a9ae9d3f3d4f1685df14e"
}

@@ -51,13 +51,35 @@ /**

assertIsDefined( lastChild, 'lastChild' );
const lastChildContentLength =
lastChild.nodeType === lastChild.TEXT_NODE
? /** @type {Text} */ ( lastChild ).data.length
: lastChild.childNodes.length;
const endContainerContentLength =
endContainer.nodeType === endContainer.TEXT_NODE
? /** @type {Text} */ ( endContainer ).data.length
: endContainer.childNodes.length;
return (
startContainer === element.firstChild &&
endContainer === element.lastChild &&
isDeepChild( startContainer, element, 'firstChild' ) &&
isDeepChild( endContainer, element, 'lastChild' ) &&
startOffset === 0 &&
endOffset === lastChildContentLength
endOffset === endContainerContentLength
);
}
/**
* Check whether the contents of the element have been entirely selected.
* Returns true if there is no possibility of selection.
*
* @param {HTMLElement|Node} query The element to check.
* @param {HTMLElement} container The container that we suspect "query" may be a first or last child of.
* @param {"firstChild"|"lastChild"} propName "firstChild" or "lastChild"
*
* @return {boolean} True if query is a deep first/last child of container, false otherwise.
*/
function isDeepChild( query, container, propName ) {
/** @type {HTMLElement | ChildNode | null} */
let candidate = container;
do {
if ( query === candidate ) {
return true;
}
candidate = candidate[ propName ];
} while ( candidate );
return false;
}

Sorry, the diff of this file is not supported yet

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