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

css-has-pseudo

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-has-pseudo - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

2

browser.js

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

function cssHasPseudo(n){var t=[],e=n.createElement("x");function r(){t.forEach(function(t){var r=[];Array.prototype.forEach.call(n.querySelectorAll(t.n),function(u){var i=Array.prototype.indexOf.call(u.parentNode.children,u)+1,o=t.t.map(function(n){return t.n+":nth-child("+i+") "+n}).join(),c=u.parentNode.querySelector(o);(t.e?!c:c)&&(r.push(u),e.innerHTML="<x "+t.r+">",u.setAttributeNode(e.children[0].attributes[0].cloneNode()),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.u.forEach(function(e){-1===r.indexOf(e)&&(e.removeAttribute(t.r),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.u=r})}function u(n){Array.prototype.forEach.call(n.cssRules||[],function(n){if(n.selectorText){var e=decodeURIComponent(n.selectorText.replace(/\\(.)/g,"$1")).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);if(e){var r=":"+(e[2]?"not-":"")+"has("+e[3].replace(/%3A/g,":").replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/%2C/g,",")+")";t.push({i:n,n:e[1],e:e[2],t:e[3].split(/\s*,\s*/),r:r,u:[]})}}else u(n)})}Array.prototype.forEach.call(n.styleSheets,u),r(),new MutationObserver(function(e){e.forEach(function(e){Array.prototype.forEach.call(e.addedNodes||[],function(n){1===n.nodeType&&n.sheet&&u(n.sheet)}),Array.prototype.push.apply(t,t.splice(0).filter(function(t){return t.i.parentStyleSheet&&t.i.parentStyleSheet.ownerNode&&n.documentElement.contains(t.i.parentStyleSheet.ownerNode)})),r()})}).observe(n,{childList:!0,subtree:!0}),n.addEventListener("focus",function(){return setImmediate(r)},!0),n.addEventListener("blur",function(){return setImmediate(r)},!0),n.addEventListener("input",function(){return setImmediate(r)})}
function cssHasPseudo(n){var t=[],r=n.createElement("x");function e(){requestAnimationFrame(function(){t.forEach(function(t){var e=[];Array.prototype.forEach.call(n.querySelectorAll(t.n),function(o){var u=Array.prototype.indexOf.call(o.parentNode.children,o)+1,i=t.t.map(function(n){return t.n+":nth-child("+u+") "+n}).join(),c=o.parentNode.querySelector(i);(t.r?!c:c)&&(e.push(o),r.innerHTML="<x "+t.e+">",o.setAttributeNode(r.children[0].attributes[0].cloneNode()),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.o.forEach(function(r){-1===e.indexOf(r)&&(r.removeAttribute(t.e),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.o=e})})}function o(n){Array.prototype.forEach.call(n.cssRules||[],function(n){if(n.selectorText){var r=decodeURIComponent(n.selectorText.replace(/\\(.)/g,"$1")).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);if(r){var e=":"+(r[2]?"not-":"")+"has("+r[3].replace(/%3A/g,":").replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/%2C/g,",")+")";t.push({u:n,n:r[1],r:r[2],t:r[3].split(/\s*,\s*/),e:e,o:[]})}}else o(n)})}Array.prototype.forEach.call(n.styleSheets,o),e(),new MutationObserver(function(r){r.forEach(function(r){Array.prototype.forEach.call(r.addedNodes||[],function(n){1===n.nodeType&&n.sheet&&o(n.sheet)}),Array.prototype.push.apply(t,t.splice(0).filter(function(t){return t.u.parentStyleSheet&&t.u.parentStyleSheet.ownerNode&&n.documentElement.contains(t.u.parentStyleSheet.ownerNode)})),e()})}).observe(n,{childList:!0,subtree:!0}),n.addEventListener("focus",e,!0),n.addEventListener("blur",e,!0),n.addEventListener("input",e)}
# Changes to CSS Has Pseudo
### 0.7.0 (November 25, 2018)
- Replaced `setImmediate` with `requestAnimationFrame` for future compatibility
### 0.6.0 (November 25, 2018)

@@ -4,0 +8,0 @@

@@ -29,39 +29,41 @@ 'use strict';

document.addEventListener('focus', () => setImmediate(transformObservedItems), true);
document.addEventListener('blur', () => setImmediate(transformObservedItems), true);
document.addEventListener('input', () => setImmediate(transformObservedItems)); // transform observed css rules
document.addEventListener('focus', transformObservedItems, true);
document.addEventListener('blur', transformObservedItems, true);
document.addEventListener('input', transformObservedItems); // transform observed css rules
function transformObservedItems() {
observedItems.forEach(item => {
const nodes = [];
Array.prototype.forEach.call(document.querySelectorAll(item.scopeSelector), element => {
const nthChild = Array.prototype.indexOf.call(element.parentNode.children, element) + 1;
const relativeSelectors = item.relativeSelectors.map(relativeSelector => item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector).join(); // find any relative :has element from the :scope element
requestAnimationFrame(() => {
observedItems.forEach(item => {
const nodes = [];
Array.prototype.forEach.call(document.querySelectorAll(item.scopeSelector), element => {
const nthChild = Array.prototype.indexOf.call(element.parentNode.children, element) + 1;
const relativeSelectors = item.relativeSelectors.map(relativeSelector => item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector).join(); // find any relative :has element from the :scope element
const relativeElement = element.parentNode.querySelector(relativeSelectors);
const shouldElementMatch = item.isNot ? !relativeElement : relativeElement;
const relativeElement = element.parentNode.querySelector(relativeSelectors);
const shouldElementMatch = item.isNot ? !relativeElement : relativeElement;
if (shouldElementMatch) {
// memorize the node
nodes.push(element); // set an attribute with an irregular attribute name
// document.createAttribute() doesn't support special characters
if (shouldElementMatch) {
// memorize the node
nodes.push(element); // set an attribute with an irregular attribute name
// document.createAttribute() doesn't support special characters
attributeElement.innerHTML = '<x ' + item.attributeName + '>';
element.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode()); // trigger a style refresh in IE and Edge
attributeElement.innerHTML = '<x ' + item.attributeName + '>';
element.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode()); // trigger a style refresh in IE and Edge
document.documentElement.style.zoom = 1;
document.documentElement.style.zoom = null;
}
}); // remove the encoded attribute from all nodes that no longer match them
document.documentElement.style.zoom = 1;
document.documentElement.style.zoom = null;
}
}); // remove the encoded attribute from all nodes that no longer match them
item.nodes.forEach(node => {
if (nodes.indexOf(node) === -1) {
node.removeAttribute(item.attributeName); // trigger a style refresh in IE and Edge
item.nodes.forEach(node => {
if (nodes.indexOf(node) === -1) {
node.removeAttribute(item.attributeName); // trigger a style refresh in IE and Edge
document.documentElement.style.zoom = 1;
document.documentElement.style.zoom = null;
}
}); // update the
document.documentElement.style.zoom = 1;
document.documentElement.style.zoom = null;
}
}); // update the
item.nodes = nodes;
item.nodes = nodes;
});
});

@@ -68,0 +70,0 @@ } // remove any observed cssrules that no longer apply

{
"name": "css-has-pseudo",
"version": "0.6.0",
"version": "0.7.0",
"description": "Style elements relative to other elements in CSS",

@@ -5,0 +5,0 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>",

@@ -44,3 +44,3 @@ # CSS Has Pseudo [<img src="http://jonathantneal.github.io/js-logo.svg" alt="" width="90" height="90" align="right">][CSS Has Pseudo]

That’s it. The script is 765 bytes and works in all browsers, including
That’s it. The script is 764 bytes and works in all browsers, including
Internet Explorer 11. With a [Mutation Observer polyfill], the script will work

@@ -47,0 +47,0 @@ down to Internet Explorer 9.

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