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.5.0 to 0.6.0

2

browser.js

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

function cssHasPseudo(n){var t=[],r=n.createElement("x");function e(){t.forEach(function(t){var e=[];Array.prototype.forEach.call(n.querySelectorAll(t.n),function(u){var o=Array.prototype.indexOf.call(u.parentNode.children,u)+1,i=t.t.map(function(n){return t.n+":nth-child("+o+") "+n}).join(),c=u.parentNode.querySelector(i);(t.r?!c:c)&&(e.push(u),r.innerHTML="<x "+t.e+">",u.setAttributeNode(r.children[0].attributes[0].cloneNode()),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.u.forEach(function(r){-1===e.indexOf(r)&&(r.removeAttribute(t.e),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.u=e})}function u(n){Array.prototype.forEach.call(n.cssRules,function(n){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({o:n,n:r[1],r:r[2],t:r[3].split(/\s*,\s*/),e:e,u:[]})}})}Array.prototype.forEach.call(n.styleSheets,u),e(),new MutationObserver(function(r){r.forEach(function(r){Array.prototype.forEach.call(r.addedNodes||[],function(n){1===n.nodeType&&n.sheet&&u(n.sheet)}),Array.prototype.push.apply(t,t.splice(0).filter(function(t){return t.o.parentStyleSheet&&t.o.parentStyleSheet.ownerNode&&n.documentElement.contains(t.o.parentStyleSheet.ownerNode)})),e()})}).observe(n,{childList:!0,subtree:!0}),n.addEventListener("focus",function(){return setImmediate(e)},!0),n.addEventListener("blur",function(){return setImmediate(e)},!0),n.addEventListener("input",function(){return setImmediate(e)})}
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)})}
# Changes to CSS Has Pseudo
### 0.6.0 (November 25, 2018)
- Fixed an issue where nested rules were not supported
### 0.5.0 (November 21, 2018)

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

@@ -77,18 +77,22 @@ 'use strict';

// walk a css rule to collect observed css rules
Array.prototype.forEach.call(styleSheet.cssRules, rule => {
// decode the selector text in all browsers to:
// [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative
const selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
Array.prototype.forEach.call(styleSheet.cssRules || [], rule => {
if (rule.selectorText) {
// decode the selector text in all browsers to:
// [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative
const selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
if (selectors) {
const attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
selectors[3].replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') + ')';
observedItems.push({
rule,
scopeSelector: selectors[1],
isNot: selectors[2],
relativeSelectors: selectors[3].split(/\s*,\s*/),
attributeName,
nodes: []
});
if (selectors) {
const attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
selectors[3].replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') + ')';
observedItems.push({
rule,
scopeSelector: selectors[1],
isNot: selectors[2],
relativeSelectors: selectors[3].split(/\s*,\s*/),
attributeName,
nodes: []
});
}
} else {
walkStyleSheet(rule);
}

@@ -95,0 +99,0 @@ });

{
"name": "css-has-pseudo",
"version": "0.5.0",
"version": "0.6.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 757 bytes and works in all browsers, including
That’s it. The script is 765 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