Skip to content

Commit

Permalink
V 1.0.4 * Minor Bug with passing adapter Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
varunsridharan committed Oct 7, 2020
1 parent a226673 commit 4bb31f0
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Security
-->

## 1.0.4 - 07/10/2020
* Minor Bug with passing adapter Fixed.

## 1.0.3 - 07/10/2020
* Changed `Dizzle.instanceID` to `Dizzle.guid`
* Updated Rollup Config To Generate Optimzed Output Files
Expand Down
35 changes: 22 additions & 13 deletions dist/dizzle.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/dizzle.es.js.map

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions dist/dizzle.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/dizzle.umd.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dizzle.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dizzle.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dizzle",
"description": "~ Simple Fast CSS Selector Engine ~",
"version": "1.0.3",
"version": "1.0.4",
"funding": "https://sva.onl/sponsor/",
"main": "dist/dizzle.umd.js",
"module": "dist/dizzle.es.js",
Expand Down
28 changes: 15 additions & 13 deletions src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import { selectorResultsCache } from "./cache";
import { _isArray } from "@varunsridharan/js-vars";
import { isString, isUndefined } from "@varunsridharan/js-is";

function nextToken( currentPos, tokens ) {
function nextToken( currentPos, tokens, adapter ) {
if( !isUndefined( tokens[ currentPos ] ) ) {
if( tokens[ currentPos ].type === 'pseudo' ) {
if( !isMarkedFunction( pesudoHandlers[ tokens[ currentPos ].id ] ) ) {
return { token: tokens[ currentPos++ ], pos: currentPos };
let token = tokens[ currentPos++ ];
token.adapter = adapter;
return { token: token, pos: currentPos };
}
} else if( tokens[ currentPos ].type !== 'combinators' && tokens[ currentPos ].type !== 'descendant' ) {
return { token: tokens[ currentPos++ ], pos: currentPos };
let token = tokens[ currentPos++ ];
token.adapter = adapter;
return { token: token, pos: currentPos };
}
}

Expand Down Expand Up @@ -57,19 +61,17 @@ export function findAdvanced( selectors, root, adapter ) {
switch( type ) {
case '*':
case 'tag':
let _selector = ( '*' === type ) ? '*' : id;
newToken = nextToken( i, tokens );
i = newToken.pos;
newToken.token.adapter = adapter;
context = context.reduce( ( nodes, el ) => combinator_callback( _selector, el, nodes, newToken.token ), [] );
let _selector = ( '*' === type ) ? '*' : id;
newToken = nextToken( i, tokens, adapter );
i = newToken.pos;
context = context.reduce( ( nodes, el ) => combinator_callback( _selector, el, nodes, newToken.token ), [] );
break;
case 'attr':
if( 'id' === id || 'class' === id ) {
newToken = nextToken( i, tokens );
i = newToken.pos;
newToken.token.adapter = adapter;
let _selector = ( 'id' === id ) ? '#' : '.';
context = context.reduce( ( nodes, el ) => combinator_callback( `${_selector}${token.val}`, el, nodes, newToken.token ), [] );
newToken = nextToken( i, tokens, adapter );
i = newToken.pos;
let _selector = ( 'id' === id ) ? '#' : '.';
context = context.reduce( ( nodes, el ) => combinator_callback( `${_selector}${token.val}`, el, nodes, newToken.token ), [] );
} else {
context = context.filter( el => attrHandler( el, token ) );
}
Expand Down
9 changes: 6 additions & 3 deletions src/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import parse from "./parser/parse";
import matcher from "./selector/matcher";
import { filterElement } from "./filter";
import { adapterCall } from "./helper";
import { isObject } from "@varunsridharan/js-is";

export function isCheckCustom( selector, elem, adapter ) {
let r = parse( selector ).reduce( ( results, tokens ) => {
let i = 0,
status = true;
while( i < tokens.length ) {
let token = tokens[ i++ ];
token.adapter = adapter;
status = ( filterElement( elem, token ) ) ? elem : false;
let token = tokens[ i++ ];
if( isObject( token ) ) {
token.adapter = adapter;
}
status = ( filterElement( elem, token ) ) ? elem : false;
}
return status;
}, true );
Expand Down

0 comments on commit 4bb31f0

Please sign in to comment.