Skip to content

Commit

Permalink
refactor(okam-build): up ref plugin component selector using class no…
Browse files Browse the repository at this point in the history
…t id
  • Loading branch information
wuhy committed Dec 6, 2018
1 parent 823516a commit e4e95b9
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions packages/okam-build/lib/processor/template/plugins/ref-plugin.js
Expand Up @@ -52,26 +52,20 @@ module.exports = {
let {file, logger} = tplOpts;
let refId = hash(file.path + '?' + refValue);
let refClass = `ref-${refId}`;
let dataRefValue;
if (isForRef) {
if (classValue) {
classValue = refClass + ' ' + classValue;
}
else {
classValue = refClass;
}
attrs.class = classValue;
dataRefValue = `.${classValue}`;
if (classValue) {
classValue = refClass + ' ' + classValue;
}
else {
attrs.id = refClass;
dataRefValue = `#${refClass}`;
classValue = refClass;
}
attrs.class = classValue;
let dataRefValue = `.${classValue}`;

attrs['data-okam-ref'] = dataRefValue;
attrs['data-okam-ref'] = isForRef ? `[]${dataRefValue}` : dataRefValue;

delete attrs.ref;

initRefInfo(refValue, dataRefValue, file, logger);
let refInfo = isForRef ? [dataRefValue] : dataRefValue;
initRefInfo(refValue, refInfo, file, logger);
}
};

0 comments on commit e4e95b9

Please sign in to comment.