refactor(hippy-vue): rm redundant code

This commit is contained in:
zoomchan-cxj
2021-04-19 11:21:01 +08:00
parent 865e50f41e
commit eed8cf08ba
4 changed files with 20 additions and 57 deletions
+6 -6
View File
@@ -59,7 +59,7 @@ module.exports = {
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false
allowSamePrecedence: false,
}],
'func-call-spacing': 'off',
'new-cap': [
@@ -70,11 +70,12 @@ module.exports = {
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
properties: false,
}
},
],
'prefer-destructuring': [
'warn',
{ VariableDeclarator: {
{
VariableDeclarator: {
array: false,
object: true,
},
@@ -117,20 +118,19 @@ module.exports = {
allowComputed: true,
},
],
// Allow import from devDependencies
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'scripts/*.js',
'packages/**/types/*.d.ts', // FIXME: seems not working
// FIXME: seems not working
'packages/**/types/*.d.ts',
'packages/**/__tests__/*.test.js',
'examples/**/scripts/*.js',
],
},
],
// Allow tsx as the jsx file
'react/jsx-filename-extension': [
'error',
@@ -8,7 +8,7 @@ import HippyReact, {
View,
} from '@hippy/react';
/* eslint import/no-webpack-loader-syntax: off */
import BACK_ICON from '!!url-loader?modules!./back-icon.png';
const SKIN_COLOR = {
+1
View File
@@ -17,6 +17,7 @@
<script>
import Vue from 'vue';
/* eslint import/no-webpack-loader-syntax: off */
import backButtonImg from '!!url-loader?modules!./back-icon.png';
let DEBUG_SUBTITLE = '';
@@ -167,7 +167,7 @@ function parseCombinator(text, start) {
};
}
function parseSelectorWithRegExpGY(text, start) {
function parseSelector(text, start) {
let end = start;
const { result, regexp } = execRegExp('whiteSpaceRegEx', text, start);
if (result) {
@@ -177,50 +177,19 @@ function parseSelectorWithRegExpGY(text, start) {
let combinator;
let expectSimpleSelector = true;
let pair = [];
do {
const simpleSelectorSequence = parseSimpleSelectorSequence(text, end);
if (!simpleSelectorSequence) {
if (expectSimpleSelector) {
return null;
} else {
break;
}
}
({ end } = simpleSelectorSequence);
if (combinator) {
pair[1] = combinator.value;
}
pair = [simpleSelectorSequence.value, undefined];
value.push(pair);
combinator = parseCombinator(text, end);
if (combinator) {
({ end } = combinator);
}
expectSimpleSelector = combinator && combinator.value !== ' ';
} while (combinator);
return {
start,
end,
value,
};
}
function parseSelectorWithoutRegExpGY(cssText, start) {
let end = start;
const { result, regexp } = execRegExp('whiteSpaceRegEx', cssText, start);
if (result) {
end = regexp.lastIndex;
let cssText;
if (REGEXP_SUPPORTING_STICKY_FLAG) {
cssText = [text];
} else {
cssText = text.split(' ');
}
const value = [];
let combinator;
let expectSimpleSelector = true;
let pair = [];
cssText.split(' ').forEach((text) => {
if (text === '') {
return;
cssText.forEach((text) => {
if (!REGEXP_SUPPORTING_STICKY_FLAG) {
if (text === '') {
return;
}
end = 0;
}
end = 0;
do {
const simpleSelectorSequence = parseSimpleSelectorSequence(text, end);
if (!simpleSelectorSequence) {
@@ -251,11 +220,4 @@ function parseSelectorWithoutRegExpGY(cssText, start) {
};
}
let parseSelector;
if (REGEXP_SUPPORTING_STICKY_FLAG) {
parseSelector = parseSelectorWithRegExpGY;
} else {
parseSelector = parseSelectorWithoutRegExpGY;
}
export default parseSelector;