Skip to content

Commit

Permalink
refactor(hippy-vue): rm redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchan-cxj committed Apr 13, 2021
1 parent fdbac85 commit 63652d7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 57 deletions.
12 changes: 6 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false
allowSamePrecedence: false,
}],
'func-call-spacing': 'off',
'new-cap': [
Expand All @@ -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,
},
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion examples/hippy-react-demo/src/shared/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions examples/hippy-vue-demo/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
62 changes: 12 additions & 50 deletions packages/hippy-vue/src/renderer/native/style/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -251,11 +220,4 @@ function parseSelectorWithoutRegExpGY(cssText, start) {
};
}

let parseSelector;
if (REGEXP_SUPPORTING_STICKY_FLAG) {
parseSelector = parseSelectorWithRegExpGY;
} else {
parseSelector = parseSelectorWithoutRegExpGY;
}

export default parseSelector;

0 comments on commit 63652d7

Please sign in to comment.