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

dresscode-bricks

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dresscode-bricks - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

44

lib/Bricks/DOM.js

@@ -187,2 +187,26 @@ Bricks.DOM = {};

/**
* Возвращает весь className элемента el. У xml-элементов, таких как svg, нет свойства className, поэтому приходится читать атрибут.
*
* @param {Node/String} el Элемент или его id.
* @returns {String}
*/
Bricks.DOM.getClassName = function(el) {
el = Bricks.DOM.getEl(el);
return typeof el.className === 'string' ? el.className : el.getAttribute('class');
};
/**
* Устанавливает className элементу el. У xml-элементов, таких как svg, нет свойства className, поэтому значение пишется в атрибут.
* @param {Node/String} el Элемент или его id.
* @param {String} className
*/
Bricks.DOM.setClassName = function(el, className) {
if (typeof el.className === 'string') {
el.className = className;
} else {
el.setAttribute('class', className);
}
};
/**
* Возвращает true, если CSS-класс className установлен у элемента el.

@@ -201,4 +225,3 @@ *

} else {
var elClassName = typeof el.className === 'string' ? el.className : el.getAttribute('class');
return new RegExp('(^|\\s)' + className + '(\\s|$)', '').test(elClassName);
return new RegExp('(^|\\s)' + className + '(\\s|$)', '').test(Bricks.DOM.getClassName(el));
}

@@ -214,11 +237,7 @@ };

Bricks.DOM.addClassName = function(el, className) {
el = Bricks.DOM.getEl(el);
if (el.classList) {
el.classList.add(className);
} else if (!Bricks.DOM.classNameExists(el, className)) {
el = Bricks.DOM.getEl(el);
if (typeof el.className === 'string') {
el.className += ' ' + className;
} else {
el.setAttribute('class', el.getAttribute('class') + ' ' + className);
}
Bricks.DOM.setClassName(el, Bricks.DOM.getClassName(el) + ' ' + className);
}

@@ -238,11 +257,6 @@ };

} else {
var isClassNameSupported = typeof el.className === 'string';
var oldClassName = isClassNameSupported ? el.className : el.getAttribute('class');
var oldClassName = Bricks.DOM.getClassName(el);
var newClassName = oldClassName.replace(new RegExp('(^|\\s)' + className + '(?=\\s|$)', 'g'), ' ');
if (oldClassName !== newClassName) {
if (isClassNameSupported) {
el.className = newClassName;
} else {
el.setAttribute('class', newClassName);
}
Bricks.DOM.setClassName(el, newClassName);
}

@@ -249,0 +263,0 @@ }

{
"name": "dresscode-bricks",
"version": "0.2.7",
"version": "0.2.8",
"author": {

@@ -5,0 +5,0 @@ "name": "Kolyaj",

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