New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bemquery-async-dom

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bemquery-async-dom - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

10

CHANGELOG.md

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

# bemquery-package-boilerplate Changelog
# bemquery-async-dom Changelog

@@ -7,2 +7,10 @@ ---

* Changed to be working with [bemquery-selector-converter](https://github.com/BEMQuery/bemquery-selector-converter).
## 0.0.2
* Fixed not working tests.
## 0.0.1
* Added `BEMQuery.prototype.html` and `BEMQuery.prototype.getStates` methods.

2

dist/bemquery-async-dom.es5.js
/*! BEMQuery v0.0.1 | (c) 2016 BEMQuery | MIT license (see LICENSE) */
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(require("bemquery-core")):typeof define==="function"&&define.amd?define(["bemquery-core"],factory):factory(global.bemquery)})(this,function(bemqueryCore){"use strict";var babelHelpers={};babelHelpers.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};babelHelpers.createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();babelHelpers;var Batch=function(){function Batch(){babelHelpers.classCallCheck(this,Batch);this.read=[];this.write=[]}babelHelpers.createClass(Batch,[{key:"add",value:function add(type,fn){if(type!=="read"&&type!=="write"){throw new TypeError("Type must be either 'read' or 'write'.")}if(typeof fn!=="function"){throw new TypeError("Task must be a function.")}this[type].push(fn)}},{key:"run",value:function run(){var _this=this;var type=arguments.length<=0||arguments[0]===undefined?"read":arguments[0];if(type!=="read"&&type!=="write"){throw new TypeError("Type must be either 'read' or 'write'.")}return new Promise(function(resolve){requestAnimationFrame(function(){var results=[];_this[type].forEach(function(fn){results.push(fn())});_this[type]=[];return resolve(results)})})}}]);return Batch}();bemqueryCore.BEMQuery.prototype.read=function(){if(!this.batch){this.batch=new Batch}return this.batch.run("read")};bemqueryCore.BEMQuery.prototype.write=function(){if(!this.batch){this.batch=new Batch}return this.batch.run("write")};bemqueryCore.BEMQuery.prototype.html=function(newHTML){var _this=this;if(!this.batch){this.batch=new Batch}if(typeof newHTML!=="undefined"){newHTML=String(newHTML);this.batch.add("write",function(){var elements=_this.elements;elements.forEach(function(element){element.innerHTML=newHTML})})}else{this.batch.add("read",function(){var elements=_this.elements;var htmls=[];elements.forEach(function(element){htmls.push(element.innerHTML)});return htmls})}return this};bemqueryCore.BEMQuery.prototype.getStates=function(){var _this=this;if(!this.batch){this.batch=new Batch}this.batch.add("read",function(){var element=_this.elements[0];var states=[];if(!element){return[]}[].forEach.call(element.classList,function(className){var state=_this.selectorEngine.converter.getStateFromClass(String(className));if(state){states.push(state)}});return states});return this}});
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(require("bemquery-core")):typeof define==="function"&&define.amd?define(["bemquery-core"],factory):factory(global.bemquery)})(this,function(bemqueryCore){"use strict";var babelHelpers={};babelHelpers.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};babelHelpers.createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();babelHelpers;var Batch=function(){function Batch(){babelHelpers.classCallCheck(this,Batch);this.read=[];this.write=[]}babelHelpers.createClass(Batch,[{key:"add",value:function add(type,fn){if(type!=="read"&&type!=="write"){throw new TypeError("Type must be either 'read' or 'write'.")}if(typeof fn!=="function"){throw new TypeError("Task must be a function.")}this[type].push(fn)}},{key:"run",value:function run(){var _this=this;var type=arguments.length<=0||arguments[0]===undefined?"read":arguments[0];if(type!=="read"&&type!=="write"){throw new TypeError("Type must be either 'read' or 'write'.")}return new Promise(function(resolve){requestAnimationFrame(function(){var results=[];_this[type].forEach(function(fn){results.push(fn())});_this[type]=[];return resolve(results)})})}}]);return Batch}();bemqueryCore.BEMQuery.prototype.read=function(){if(!this.batch){this.batch=new Batch}return this.batch.run("read")};bemqueryCore.BEMQuery.prototype.write=function(){if(!this.batch){this.batch=new Batch}return this.batch.run("write")};bemqueryCore.BEMQuery.prototype.html=function(newHTML){var _this=this;if(!this.batch){this.batch=new Batch}if(typeof newHTML!=="undefined"){newHTML=String(newHTML);this.batch.add("write",function(){var elements=_this.elements;elements.forEach(function(element){element.innerHTML=newHTML})})}else{this.batch.add("read",function(){var elements=_this.elements;var htmls=[];elements.forEach(function(element){htmls.push(element.innerHTML)});return htmls})}return this};function processClasses(converter,element){var states=[];[].forEach.call(element.classList,function(className){var state=converter.getStateFromClass(String(className));if(state){states.push(state)}});return states}bemqueryCore.BEMQuery.prototype.getStates=function(){var _this=this;if(!this.batch){this.batch=new Batch}var elements=this.elements;this.batch.add("read",function(){var result=[];elements.forEach(function(element){result.push(processClasses(_this.converter,element))});return result});return this}});
//# sourceMappingURL=./dist/bemquery-async-dom.es5.js.map

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

/*! BEMQuery v0.0.1 | (c) 2016 BEMQuery | MIT license (see LICENSE) */
/*! bemquery-async-dom v0.1.0 | (c) 2016 BEMQuery team | MIT license (see LICENSE) */
import { BEMQuery } from 'bemquery-core';

@@ -130,4 +130,18 @@

function processClasses( converter, element ) {
const states = [];
[].forEach.call( element.classList, ( className ) => {
const state = converter.getStateFromClass( String( className ) );
if ( state ) {
states.push( state );
}
} );
return states;
}
/**
* Method for getting states from all elements in collection
* Method for getting states from all elements in collection.
*

@@ -142,19 +156,12 @@ * @return {BEMQuery} Current BEMQuery instance.

const elements = this.elements;
this.batch.add( 'read', () => {
const element = this.elements[ 0 ];
const states = [];
const result = [];
if ( !element ) {
return [];
}
[].forEach.call( element.classList, ( className ) => {
const state = this.selectorEngine.converter.getStateFromClass( String( className ) );
if ( state ) {
states.push( state );
}
elements.forEach( ( element ) => {
result.push( processClasses( this.converter, element ) );
} );
return states;
return result;
} );

@@ -161,0 +168,0 @@

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

/*! BEMQuery v0.0.1 | (c) 2016 BEMQuery | MIT license (see LICENSE) */
/*! bemquery-async-dom v0.1.0 | (c) 2016 BEMQuery team | MIT license (see LICENSE) */
(function (global, factory) {

@@ -134,4 +134,18 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bemquery-core')) :

function processClasses( converter, element ) {
const states = [];
[].forEach.call( element.classList, ( className ) => {
const state = converter.getStateFromClass( String( className ) );
if ( state ) {
states.push( state );
}
} );
return states;
}
/**
* Method for getting states from all elements in collection
* Method for getting states from all elements in collection.
*

@@ -146,19 +160,12 @@ * @return {BEMQuery} Current BEMQuery instance.

const elements = this.elements;
this.batch.add( 'read', () => {
const element = this.elements[ 0 ];
const states = [];
const result = [];
if ( !element ) {
return [];
}
[].forEach.call( element.classList, ( className ) => {
const state = this.selectorEngine.converter.getStateFromClass( String( className ) );
if ( state ) {
states.push( state );
}
elements.forEach( ( element ) => {
result.push( processClasses( this.converter, element ) );
} );
return states;
return result;
} );

@@ -165,0 +172,0 @@

{
"name": "bemquery-async-dom",
"version": "0.0.1",
"description": "BEM selector engine",
"version": "0.1.0",
"description": "BEM asynchronous DOM module",
"main": "dist/bemquery-async-dom.umd.js",

@@ -14,4 +14,3 @@ "jsnext:main": "dist/bemquery-async-dom.js",

"prebuild": "npm test",
"minify": "uglifyjs ./dist/bemquery-async-dom.es5.js -o ./dist/bemquery-async-dom.es5.js --comments=/^/*!/ --source-map=./dist/bemquery-async-dom.es5.js.map",
"build": "rollup -c config/rollup/umd.js && rollup -c config/rollup/es6.js && rollup -c config/rollup/es5.js && npm run minify",
"build": "rollup -c config/rollup/umd.js && rollup -c config/rollup/es6.js && rollup -c config/rollup/es5.js",
"build-docs": "jsdoc -c config/jsdoc/default.json ./src",

@@ -29,4 +28,4 @@ "publish-docs": "npm run build-docs && git checkout gh-pages && ncp docs/dist ./ && git add -A && git commit -m \"[ci skip] Updated docs.\" && git push origin gh-pages && git checkout master",

"BEM",
"selector",
"engine"
"BEMQuery",
"DOM"
],

@@ -37,3 +36,6 @@ "files": [

],
"author": "Comandeer",
"author": {
"name": "BEMQuery team",
"url": "https://github.com/BEMQuery"
},
"license": "MIT",

@@ -48,3 +50,3 @@ "bugs": {

"chai": "^3.5.0",
"eslint": "^2.8.0",
"eslint": "^2.9.0",
"in-publish": "^2.0.0",

@@ -54,9 +56,9 @@ "ink-docstrap": "^1.1.4",

"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.2",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^0.5.5",
"karma-firefox-launcher": "^0.1.7",
"karma-fixture": "^0.2.6",
"karma-html2js-preprocessor": "^0.1.0",
"karma-html2js-preprocessor": "^1.0.0",
"karma-json-fixtures-preprocessor": "0.0.6",
"karma-mocha": "^0.2.2",
"karma-mocha": "^1.0.1",
"karma-rollup-preprocessor": "^2.0.1",

@@ -67,3 +69,3 @@ "karma-sinon-chai": "^1.2.0",

"ncp": "^2.0.0",
"rollup": "^0.26.1",
"rollup": "^0.26.2",
"rollup-plugin-babel": "^2.4.0",

@@ -73,3 +75,4 @@ "rollup-plugin-commonjs": "^2.2.1",

"rollup-plugin-node-resolve": "^1.5.0",
"sinon": "^1.17.3",
"rollup-plugin-uglify": "^0.3.1",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",

@@ -76,0 +79,0 @@ "uglify-js": "^2.6.2"

@@ -11,3 +11,3 @@ require( 'bemquery-selector-engine/package.json' );

const package = url.parse( request.url, true ).query.package;
response.end( fs.readFileSync( require.resolve( 'bemquery-' + package ) ) );

@@ -26,3 +26,3 @@ };

<p>Example</p>
<script src="${endpoint}?package=selector-engine"></script>

@@ -32,5 +32,13 @@ script src="${endpoint}?package=core"></script>

<script>
const bemQuery = bemquery.default( 'block element' );
bemQuery.html().getStates().read().then( ( values ) => {
const html = values[ 0 ][ 0 ];
const states = values[ 1 ];
console.log( html ); // Test
console.log( states ); // [ 'state1', 'state2' ]
} );
</script>
</body>
</html>`;

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