Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gonzales 3.2 - Fix no mergeable selectors #556

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 0 additions & 107 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,112 +231,6 @@ helpers.stripLastSpace = function (selector) {

};

/**
* Scans through our selectors and keeps track of the order of selectors and delimiters
* @param {object} selector - the current selector tree from our AST
* @returns {array} mappedElements - an array / list representing the order of selectors and delimiters encountered
*/

helpers.mapDelims = function (val) {

if (val.type === 'simpleSelector') {
return 's';
}

if (val.type === 'delimiter') {
return 'd';
}

return false;
};

/**
* Constructs a syntax complete selector
* @param {object} node - the current node / part of our selector
* @returns {object} constructedSelector - The constructed selector
* @returns {string} constructedSelector.content - The selector string
* @returns {string} constructedSelector.type - The type of the selector
*/
helpers.constructSelector = function (node) {
var content = node.content,
type = '';

if (node.type === 'id') {
content = '#' + node.content;
type = 'id';
}

else if (node.type === 'class') {
content = '.' + node.content;
type = 'class';
}

else if (node.type === 'ident') {
content = node.content;
type = 'selector';
}

else if (node.type === 'attribute') {
var selector = '[';

node.forEach(function (attrib) {
var selectorPiece = helpers.constructSelector(attrib);

selector += selectorPiece.content;
});

content = selector + ']';
type = 'attribute';
}

else if (node.type === 'pseudoClass') {
content = ':' + node.content;
type = 'pseudoClass';
}

else if (node.type === 'pseudoElement') {
content = '::' + node.content;
type = 'pseudoElement';
}

else if (node.type === 'nth') {
content = '(' + node.content + ')';
type = 'nth';
}

else if (node.type === 'nthSelector') {
var nthSelector = ':';

node.forEach(function (attrib) {
var selectorPiece = helpers.constructSelector(attrib);

nthSelector += selectorPiece.content;
});

content = nthSelector;
type = 'nthSelector';
}

else if (node.type === 'space') {
content = ' ';
}

else if (node.type === 'parentSelector') {
content = node.content;
type = 'parentSelector';
}

else if (node.type === 'combinator') {
content = node.content;
type = 'combinator';
}

return {
content: content,
type: type
};
};

/**
* Checks the current selector value against the previous selector value and assesses whether they are
* a) currently an enforced selector type for nesting (user specified - all true by default)
Expand Down Expand Up @@ -386,7 +280,6 @@ helpers.attemptTraversal = function (node, traversalPath) {
currentNodeList.forEach(processChildNode);
currentNodeList = nextNodeList;
}

return currentNodeList;
};

Expand Down
Loading