Skip to content

Commit

Permalink
breakin-ish: rename noCssTransform to noCSSTransform and add noCssTra…
Browse files Browse the repository at this point in the history
…nsform alias - fixes #3273
  • Loading branch information
evs-chris committed Oct 15, 2018
1 parent 34db700 commit 898013f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Ractive/config/custom/css/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export function initCSS(options, target, proto) {
css = evalCSS(target, css);
}

const def = { transform: !options.noCssTransform };
const def = {
transform: 'noCSSTransform' in options ? !options.noCSSTransform : !options.noCssTransform
};

defineProperty(target, '_cssDef', { configurable: true, value: def });

Expand Down
2 changes: 1 addition & 1 deletion src/Ractive/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ export default {

// css:
css: null,
noCssTransform: false
noCSSTransform: false
};
4 changes: 2 additions & 2 deletions tests/browser/init/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function() {
'complete',
'nestedTransitions',
'css',
'noCssTransform'
'noCSSTransform'
];

const actualDefaults = expectedDefaults.filter(key => Ractive.defaults.hasOwnProperty(key));
Expand All @@ -62,7 +62,7 @@ export default function() {
'isolated',
'lazy',
'nestedTransitions',
'noCssTransform',
'noCSSTransform',
'noIntro',
'noOutro',
'preserveWhitespace',
Expand Down
26 changes: 25 additions & 1 deletion tests/browser/render/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function() {
const Widget = Ractive.extend({
template: '<p class="unencapsulated">red</p>',
css: '.unencapsulated { color: red; }',
noCssTransform: true
noCSSTransform: true
});

const ractive = new Ractive({
Expand All @@ -89,6 +89,30 @@ export default function() {
ractive.teardown().then(done);
});

test('CSS encapsulation transformation is optional with old noCssTransform', t => {
const done = t.async();

const Widget = Ractive.extend({
template: '<p class="unencapsulated2">green</p>',
css: '.unencapsulated2 { color: green; }',
noCssTransform: true
});

const ractive = new Ractive({
el: fixture,
template: '<p class="unencapsulated2">green</p><Widget/>',
components: { Widget }
});

const paragraphs = ractive.findAll('p');

t.equal(getHexColor(paragraphs[0]), hexCodes.green);
t.equal(getHexColor(paragraphs[1]), hexCodes.green);

// we need to clean up after ourselves otherwise the global styles remain in the DOM!
ractive.teardown().then(done);
});

test('Comments do not break transformed CSS', t => {
const Widget = Ractive.extend({
template: '<p>foo</p>',
Expand Down

0 comments on commit 898013f

Please sign in to comment.