提交
This commit is contained in:
14
node_modules/postcss-px-to-viewport/src/pixel-unit-regexp.js
generated
vendored
Normal file
14
node_modules/postcss-px-to-viewport/src/pixel-unit-regexp.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// excluding regex trick: http://www.rexegg.com/regex-best-trick.html
|
||||
|
||||
// Not anything inside double quotes
|
||||
// Not anything inside single quotes
|
||||
// Not anything inside url()
|
||||
// Any digit followed by px
|
||||
// !singlequotes|!doublequotes|!url()|pixelunit
|
||||
function getUnitRegexp(unit) {
|
||||
return new RegExp('"[^"]+"|\'[^\']+\'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)' + unit, 'g');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getUnitRegexp
|
||||
};
|
||||
106
node_modules/postcss-px-to-viewport/src/prop-list-matcher.js
generated
vendored
Normal file
106
node_modules/postcss-px-to-viewport/src/prop-list-matcher.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
var filterPropList = {
|
||||
exact: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^[^\*\!]+$/);
|
||||
});
|
||||
},
|
||||
contain: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^\*.+\*$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(1, m.length - 2);
|
||||
});
|
||||
},
|
||||
endWith: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^\*[^\*]+$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(1);
|
||||
});
|
||||
},
|
||||
startWith: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^[^\*\!]+\*$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(0, m.length - 1);
|
||||
});
|
||||
},
|
||||
notExact: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^\![^\*].*$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(1);
|
||||
});
|
||||
},
|
||||
notContain: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^\!\*.+\*$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(2, m.length - 3);
|
||||
});
|
||||
},
|
||||
notEndWith: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^\!\*[^\*]+$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(2);
|
||||
});
|
||||
},
|
||||
notStartWith: function (list) {
|
||||
return list.filter(function (m) {
|
||||
return m.match(/^\![^\*]+\*$/);
|
||||
}).map(function (m) {
|
||||
return m.substr(1, m.length - 2);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function createPropListMatcher(propList) {
|
||||
var hasWild = propList.indexOf('*') > -1;
|
||||
var matchAll = (hasWild && propList.length === 1);
|
||||
var lists = {
|
||||
exact: filterPropList.exact(propList),
|
||||
contain: filterPropList.contain(propList),
|
||||
startWith: filterPropList.startWith(propList),
|
||||
endWith: filterPropList.endWith(propList),
|
||||
notExact: filterPropList.notExact(propList),
|
||||
notContain: filterPropList.notContain(propList),
|
||||
notStartWith: filterPropList.notStartWith(propList),
|
||||
notEndWith: filterPropList.notEndWith(propList)
|
||||
};
|
||||
return function (prop) {
|
||||
if (matchAll) return true;
|
||||
return (
|
||||
(
|
||||
hasWild ||
|
||||
lists.exact.indexOf(prop) > -1 ||
|
||||
lists.contain.some(function (m) {
|
||||
return prop.indexOf(m) > -1;
|
||||
}) ||
|
||||
lists.startWith.some(function (m) {
|
||||
return prop.indexOf(m) === 0;
|
||||
}) ||
|
||||
lists.endWith.some(function (m) {
|
||||
return prop.indexOf(m) === prop.length - m.length;
|
||||
})
|
||||
) &&
|
||||
!(
|
||||
lists.notExact.indexOf(prop) > -1 ||
|
||||
lists.notContain.some(function (m) {
|
||||
return prop.indexOf(m) > -1;
|
||||
}) ||
|
||||
lists.notStartWith.some(function (m) {
|
||||
return prop.indexOf(m) === 0;
|
||||
}) ||
|
||||
lists.notEndWith.some(function (m) {
|
||||
return prop.indexOf(m) === prop.length - m.length;
|
||||
})
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
filterPropList,
|
||||
createPropListMatcher
|
||||
};
|
||||
Reference in New Issue
Block a user