Skip to content

Commit 5f59ed9

Browse files
committedMar 2, 2018
chore: Code cleanup.
- Inheritable now implements SelectorFactory - setBase is only available on Block objects - Remove LocalScope from project. Not needed after refactor. - Webpack loader exports as default as expected again. - Remove Block's internal OBJ_REF_SPLITTER path parser. - Remove unionInto utility from main package exports.
1 parent eb8abe2 commit 5f59ed9

File tree

18 files changed

+193
-237
lines changed

18 files changed

+193
-237
lines changed
 

Diff for: ‎.vscode/settings.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{
2-
}
1+
{}

Diff for: ‎packages/css-blocks/src/Block/Block.ts

+10-36
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,18 @@ import { OptionsReader } from "../OptionsReader";
2020
import { SourceLocation } from "../SourceLocation";
2121
import { CssBlockError, InvalidBlockSyntax } from "../errors";
2222
import { FileIdentifier } from "../importing";
23-
import { LocalScopedContext } from "../util/LocalScope";
2423

2524
import { BlockClass } from "./BlockClass";
2625
import { Inheritable } from "./Inheritable";
2726
import { Styles } from "./Styles";
2827

29-
export const OBJ_REF_SPLITTER = (s: string): [string, string] | undefined => {
30-
let index = s.indexOf(".");
31-
if (index < 0) index = s.indexOf("[");
32-
if (index >= 0) {
33-
return [s.substr(0, index), s.substring(index)];
34-
}
35-
return;
36-
};
37-
38-
export class Block extends Inheritable<Block, Block, never, BlockClass> {
28+
export class Block
29+
extends Inheritable<Block, Block, never, BlockClass> {
3930
private _rootClass: BlockClass;
4031
private _blockReferences: ObjectDictionary<Block> = {};
4132
private _blockReferencesReverseLookup: Map<Block, string> = new Map();
4233
private _identifier: FileIdentifier;
4334
private _implements: Block[] = [];
44-
private _localScope: LocalScopedContext<Block, Styles>;
4535
private hasHadNameReset = false;
4636
/**
4737
* array of paths that this block depends on and, if changed, would
@@ -51,13 +41,10 @@ export class Block extends Inheritable<Block, Block, never, BlockClass> {
5141
private _dependencies: Set<string>;
5242

5343
public stylesheet?: postcss.Root;
54-
public readonly parsedRuleSelectors: WeakMap<postcss.Rule, ParsedSelector[]>;
5544

5645
constructor(name: string, identifier: FileIdentifier) {
5746
super(name);
5847
this._identifier = identifier;
59-
this.parsedRuleSelectors = new WeakMap();
60-
this._localScope = new LocalScopedContext<Block, Styles>(OBJ_REF_SPLITTER, this);
6148
this._dependencies = new Set<string>();
6249
this._rootClass = new BlockClass(ROOT_CLASS, this);
6350
this.addClass(this._rootClass);
@@ -74,27 +61,16 @@ export class Block extends Inheritable<Block, Block, never, BlockClass> {
7461
this.hasHadNameReset = true;
7562
}
7663

77-
get rootClass(): BlockClass {
78-
return this._rootClass;
79-
}
80-
81-
/// Start of methods to implement LocalScope<Block, Style>
82-
subScope(name: string): LocalScopedContext<Block, Styles> | undefined {
83-
let block = this._blockReferences[name];
84-
if (block) {
85-
return block._localScope;
86-
} else {
87-
return;
88-
}
64+
/**
65+
* Sets the base Block that this Block inherits from.
66+
* @prop base Block The new base Block.
67+
*/
68+
public setBase(base: Block) {
69+
this._base = base;
8970
}
9071

91-
lookupLocal(name: string): Styles | undefined {
92-
let blockRef = this._blockReferences[name];
93-
if (blockRef) {
94-
return blockRef.rootClass;
95-
} else {
96-
return this.all(false).find(o => o.asSource() === name);
97-
}
72+
get rootClass(): BlockClass {
73+
return this._rootClass;
9874
}
9975

10076
/**
@@ -140,8 +116,6 @@ export class Block extends Inheritable<Block, Block, never, BlockClass> {
140116
return state || klass || undefined;
141117
}
142118

143-
/// End of methods to implement LocalScope<Block, Style>
144-
145119
/**
146120
* Add an absolute, normalized path as a compilation dependency. This is used
147121
* to invalidate caches and trigger watchers when those files change.

Diff for: ‎packages/css-blocks/src/Block/BlockClass.ts

+16-10
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,23 @@ export class BlockClass extends Style<BlockClass, Block, Block, StateGroup> {
4343
let states = group.states();
4444
return filter ? states.filter(s => s.name === filter) : states;
4545
}
46+
47+
/**
48+
* Ensure that a `StateGroup` with the given name exists. If the `StateGroup`
49+
* does not exist, it is created.
50+
* @param name The State group to ensure exists.
51+
* @param vallue The State's value to ensure exists.
52+
* @returns The State object.
53+
*/
4654
public ensureGroup(name: string): StateGroup { return this.ensureChild(name); }
55+
56+
/**
57+
* Ensure that a `State` within the provided group exists. If the `State`
58+
* does not exist, it is created.
59+
* @param name The State group to ensure exists.
60+
* @param vallue The State's value to ensure exists.
61+
* @returns The State object.
62+
*/
4763
public ensureState(name: string, value?: string): State {
4864
return this.ensureGroup(name).ensureState(value);
4965
}
@@ -156,16 +172,6 @@ export class BlockClass extends Style<BlockClass, Block, Block, StateGroup> {
156172
return result;
157173
}
158174

159-
/**
160-
* Ensure that a `SubState` with the given `subStateName` exists belonging to
161-
* the state named `stateName`. If the state does not exist, it is created.
162-
* @param stateName The State's name to ensure.
163-
* @param subStateName Optional state group for lookup/registration
164-
*/
165-
ensureSubState(groupName: string, subStateName: string): State {
166-
return this.ensureGroup(groupName).ensureState(subStateName);
167-
}
168-
169175
/**
170176
* Group getter. Returns a list of State objects in the requested group that are defined
171177
* against this specific class. This does not take inheritance into account.

Diff for: ‎packages/css-blocks/src/Block/Inheritable.ts

+37-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* @module Block/BlockTree/Inheritable
1313
*/
1414
import { ObjectDictionary } from "@opticss/util";
15+
import { ParsedSelector, parseSelector, SelectorFactory } from "opticss";
16+
import * as postcss from "postcss";
1517

1618
/* tslint:disable:prefer-whatever-to-any */
1719
export type AnyNode = Inheritable<any, any, any, any>;
@@ -21,14 +23,15 @@ export abstract class Inheritable<
2123
Root extends Inheritable<any, Root, never, AnyNode> | Self,
2224
Parent extends Inheritable<any, Root, AnyNode | null, Self> | null,
2325
Child extends Inheritable<any, Root, Self, AnyNode | never> | never
24-
> {
26+
> implements SelectorFactory {
2527
/* tslint:enable:prefer-whatever-to-any */
2628

2729
protected _name: string;
2830
protected _base: Self | undefined;
2931
protected _root: Root | Self;
3032
protected _parent: Parent | null;
3133
protected _children: Map<string, Child> = new Map();
34+
private readonly parsedRuleSelectors: WeakMap<postcss.Rule, ParsedSelector[]> | null;
3235

3336
/**
3437
* Given a parent that is a base class of this style, retrieve this style's
@@ -44,7 +47,10 @@ export abstract class Inheritable<
4447
constructor(name: string, parent?: Parent) {
4548
this._name = name;
4649
this._parent = parent || null;
47-
this._root = parent ? parent.root : this.asSelf(); // `Root` is only set to `Self` for `Source` nodes.
50+
// `Root` is only set to `Self` for `Source` nodes.
51+
this._root = parent ? parent.root : this.asSelf();
52+
// `parsedRuleSelectors cache is only created if this is a root node.
53+
this.parsedRuleSelectors = this.isRootNode ? new WeakMap() : null;
4854
}
4955

5056
public get name(): string { return this._name; }
@@ -87,6 +93,13 @@ export abstract class Inheritable<
8793
return this._root as Root;
8894
}
8995

96+
/**
97+
* @returns A boolean indicating if this is the root node in the Inheritable tree or not.
98+
*/
99+
public get isRootNode(): boolean {
100+
return this._root === this.asSelf();
101+
}
102+
90103
/**
91104
* The `block` property is an alias for `root`. This isn't the dryest place to put
92105
* this line, but every extension re-declared this interface itself and I wanted it
@@ -95,14 +108,6 @@ export abstract class Inheritable<
95108
*/
96109
public get block(): Root { return this.root; }
97110

98-
/**
99-
* Sets the base node that this node inherits from. Must be of same type.
100-
* @prop base The new base node.
101-
*/
102-
public setBase(base: Self) {
103-
this._base = base;
104-
}
105-
106111
/**
107112
* Compute all block objects that are implied by this block object through
108113
* inheritance. Does not include this object or the styles it implies through
@@ -172,7 +177,7 @@ export abstract class Inheritable<
172177
if (!this._children.has(name)) {
173178
this.setChild(key, this.newChild(name));
174179
}
175-
return this._children.get(key) as Child;
180+
return this._children.get(key)!;
176181
}
177182

178183
/**
@@ -204,6 +209,27 @@ export abstract class Inheritable<
204209
return out;
205210
}
206211

212+
/**
213+
* Every Block tree maintains its own local cache of parsed selectors.
214+
* From any sub-inheritable, or from the root inheritable itself,
215+
* given a PostCSS Rule, ensure it is present in the root Block's parsed rule
216+
* selectors cache, and return the ParsedSelector array.
217+
* @param rule PostCSS Rule
218+
* @return ParsedSelector array
219+
*/
220+
public getParsedSelectors(rule: postcss.Rule): ParsedSelector[] {
221+
if (!this.isRootNode) {
222+
return this.root.getParsedSelectors(rule);
223+
}
224+
225+
let selectors = this.parsedRuleSelectors!.get(rule);
226+
if (!selectors) {
227+
selectors = parseSelector(rule);
228+
this.parsedRuleSelectors!.set(rule, selectors);
229+
}
230+
return selectors;
231+
}
232+
207233
// TypeScript can't figure out that `this` is the `Self` so this private
208234
// method casts it in a few places where it's needed.
209235
private asSelf(): Self {

Diff for: ‎packages/css-blocks/src/Block/RulesetContainer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
import { MultiMap, TwoKeyMultiMap } from "@opticss/util";
1212
import * as propParser from "css-property-parser";
13-
import { ParsedSelector, parseSelector } from "opticss";
13+
import { ParsedSelector } from "opticss";
1414
import * as postcss from "postcss";
1515

1616
import { BLOCK_PROP_NAMES, RESOLVE_RE, SELF_SELECTOR } from "../BlockSyntax";
@@ -115,7 +115,7 @@ export class RulesetContainer<S extends Styles> {
115115
*/
116116
addRuleset(file: string, rule: postcss.Rule) {
117117
let style = this.parent;
118-
let selectors: ParsedSelector[] = parseSelector(rule);
118+
let selectors: ParsedSelector[] = style.getParsedSelectors(rule);
119119

120120
selectors.forEach((selector) => {
121121
let ruleSet = new Ruleset(file, rule, style);

Diff for: ‎packages/css-blocks/src/Block/StateGroup.ts

+66-10
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,77 @@ export class StateGroup extends Inheritable<StateGroup, Block, BlockClass, State
2323
private _universalState: State | undefined;
2424
private _sourceAttributes: Attr[] | undefined;
2525

26-
constructor(name: string, parent: BlockClass) {
27-
super(name, parent);
28-
}
29-
3026
protected newChild(name: string): State { return new State(name, this); }
3127

28+
/**
29+
* @returns If this State Group contains anything but the "Universal" State.
30+
**/
3231
get hasSubStates(): boolean { return this._hasSubStates; }
32+
33+
/**
34+
* @returns If this State Group only contains the "Universal" State.
35+
**/
36+
get isBooleanState(): boolean { return !this._hasSubStates; }
37+
38+
/**
39+
* @returns The "Universal" State, or `undefined`.
40+
**/
3341
get universalState(): State | undefined { return this._universalState; }
42+
43+
/**
44+
* @returns This State's parent `BlockClass`
45+
**/
3446
get blockClass(): BlockClass { return this.parent; }
3547

48+
/**
49+
* @returns An array of all `State`s contained in this `StateGroup`.
50+
**/
3651
states(): State[] { return this.children(); }
52+
53+
/**
54+
* @returns A hash of all `State`s contained in this `StateGroup`.
55+
**/
3756
statesHash(): ObjectDictionary<State> { return this.childrenHash(); }
57+
58+
/**
59+
* @returns An Map of all `State`s contained in this `StateGroup`.
60+
**/
3861
statesMap(): Map<string, State> { return this.childrenMap(); }
39-
ensureState(name?: string) {
40-
name = name || UNIVERSAL_STATE;
62+
63+
/**
64+
* Ensures that a state of name `name` exists in this State group. If no
65+
* `State` exists, one is created. If no name is passed, it ensures the
66+
* "Universal" State.
67+
* @param name string The `State` name to ensure.
68+
* @returns The `State`
69+
**/
70+
ensureState(name: string = UNIVERSAL_STATE) {
4171
let state = this.ensureChild(name);
4272
if (name !== UNIVERSAL_STATE) { this._hasSubStates = true; }
4373
else { this._universalState = state; }
4474
return state;
4575
}
46-
getState(name: string): State | null { return name ? this.getChild(name) : this.getChild(UNIVERSAL_STATE); }
47-
resolveState(name: string): State | null { return name ? this.resolveChild(name) : this.resolveChild(UNIVERSAL_STATE); }
4876

4977
/**
50-
* returns whether this state has any sub states defined directly
51-
* or inherited.
78+
* Get a StateGroup's own (read: non-inherited) `State` of name
79+
* `name` from this `StateGroup`. If no name is passed, it tries
80+
* to retrieve the "Universal" State.
81+
* @param name string The name of the `State` to retrieve.
82+
* @returns The `State` or `undefined`.
83+
**/
84+
getState(name: string = UNIVERSAL_STATE): State | null { return this.getChild(name); }
85+
86+
/**
87+
* Get a StateGroup's own or inherited`State` of name `name` from this
88+
* `StateGroup` or its base. If no name is passed, it tries to retrieve
89+
* the "Universal" State.
90+
* @param name string The name of the `State` to retrieve.
91+
* @returns The `State` or `undefined`.
92+
**/
93+
resolveState(name: string = UNIVERSAL_STATE): State | null { return this.resolveChild(name); }
94+
95+
/**
96+
* @returns whether this state has any sub states defined directly or inherited.
5297
*/
5398
hasResolvedStates(): boolean {
5499
return !!(this.hasSubStates || this.base && this.base.hasResolvedStates());
@@ -70,6 +115,9 @@ export class StateGroup extends Inheritable<StateGroup, Block, BlockClass, State
70115
return resolved;
71116
}
72117

118+
/**
119+
* @returns The bare state selector with no qualifying `BlockClass` name.
120+
*/
73121
unqualifiedSource(value?: string): string {
74122
return `[state|${this.name}${(value && value !== UNIVERSAL_STATE) ? `=${value}` : ""}]`;
75123
}
@@ -86,6 +134,10 @@ export class StateGroup extends Inheritable<StateGroup, Block, BlockClass, State
86134
return (this.blockClass.isRoot ? "" : this.blockClass.asSource()) + this.unqualifiedSource(value);
87135
}
88136

137+
/**
138+
* Emit analysis attributes for the `State` values this
139+
* `StateGroup` represents in it's authored source format.
140+
*/
89141
asSourceAttributes(): Attr[] {
90142
if (!this._sourceAttributes) {
91143
this._sourceAttributes = [];
@@ -141,6 +193,10 @@ export class StateGroup extends Inheritable<StateGroup, Block, BlockClass, State
141193
}
142194
}
143195

196+
/**
197+
* @param o object The object to test.
198+
* @returns If the supplied object `o` is a `StateGroup`.
199+
*/
144200
export function isStateGroup(o: object): o is StateGroup {
145201
return o instanceof StateGroup;
146202
}

Diff for: ‎packages/css-blocks/src/Block/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Block, isBlock, OBJ_REF_SPLITTER } from "./Block";
1+
export { Block, isBlock } from "./Block";
22
export { BlockClass, isBlockClass } from "./BlockClass";
33
export { StateGroup } from "./StateGroup";
44
export { State, isState } from "./State";

Diff for: ‎packages/css-blocks/src/BlockCompiler/ConflictResolver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class ConflictResolver {
8787
let handledObjects = new Conflicts<Style>();
8888

8989
// For each key selector:
90-
let parsedSelectors = parseSelector(rule);
90+
let parsedSelectors = block.getParsedSelectors(rule);
9191
parsedSelectors.forEach((sel) => {
9292
let key = sel.key;
9393

@@ -232,7 +232,7 @@ export class ConflictResolver {
232232
// Something to consider: when resolving against a sub-block that has overridden a property, do we need
233233
// to include the base object selector(s) in the key selector as well?
234234
let query = new QueryKeySelector(other);
235-
let result = query.execute(root);
235+
let result = query.execute(root, other.block);
236236
let foundConflict: ConflictType = ConflictType.noConflict;
237237
let resolvedSelectors = new Set<string>();
238238
curSel.forEach((cs) => {

Diff for: ‎packages/css-blocks/src/BlockCompiler/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { parseSelector } from "opticss";
21
import * as postcss from "postcss";
32

43
import { Block } from "../Block";
@@ -46,7 +45,7 @@ export class BlockCompiler {
4645
// Resolve inheritance based conflicts
4746
resolver.resolveInheritance(root, block);
4847
root.walkRules((rule) => {
49-
let parsedSelectors = parseSelector(rule);
48+
let parsedSelectors = block.getParsedSelectors(rule);
5049
rule.selector = parsedSelectors.map(s => block.rewriteSelectorToString(s, this.opts)).join(",\n");
5150
});
5251

Diff for: ‎packages/css-blocks/src/BlockParser/features/assert-foreign-global-state.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { parseSelector } from "opticss";
21
import * as postcss from "postcss";
32

43
import { Block } from "../../Block";
@@ -22,7 +21,7 @@ export async function assertForeignGlobalState(root: postcss.Root, block: Block,
2221

2322
root.walkRules((rule) => {
2423

25-
let parsedSelectors = parseSelector(rule);
24+
let parsedSelectors = block.getParsedSelectors(rule);
2625

2726
parsedSelectors.forEach((iSel) => {
2827

Diff for: ‎packages/css-blocks/src/BlockParser/features/construct-block.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { assertNever } from "@opticss/util";
2-
import { CompoundSelector, ParsedSelector, parseSelector } from "opticss";
2+
import { CompoundSelector, ParsedSelector } from "opticss";
33
import * as postcss from "postcss";
44
import selectorParser = require("postcss-selector-parser");
55

@@ -35,6 +35,20 @@ function shouldBeParsedAsBlockSelector(rule: postcss.Rule): boolean {
3535
return !(rule.parent && rule.parent.type === "atrule" && (rule.parent).name === "keyframes");
3636
}
3737

38+
/**
39+
* Pull getParsedSelectors try-catch out to prevent de-opt of main walkRules function.
40+
* @param block Block The block to fetch ParsedSelectors from.
41+
* @param rule postcss.Rule The postcss rule to parse.
42+
* @param file string The filepath of the file we are parsing for error reporting.
43+
* @returns The ParsedSelector array.
44+
**/
45+
function getParsedSelectors(block: Block, rule: postcss.Rule, file: string): ParsedSelector[] {
46+
let res;
47+
try { res = block.getParsedSelectors(rule); }
48+
catch (e) { throw new errors.InvalidBlockSyntax(e.message, sourceLocation(file, rule)); }
49+
return res;
50+
}
51+
3852
export async function constructBlock(root: postcss.Root, block: Block, file: string): Promise<Block> {
3953

4054
let styleRuleTuples: Set<[Style, postcss.Rule]> = new Set();
@@ -46,9 +60,7 @@ export async function constructBlock(root: postcss.Root, block: Block, file: str
4660
if (!shouldBeParsedAsBlockSelector(rule)) { return; }
4761

4862
// Fetch the parsed selectors list. Throw a helpful error if we can't parse.
49-
let parsedSelectors;
50-
try { parsedSelectors = parseSelector(rule); }
51-
catch (e) { throw new errors.InvalidBlockSyntax(e.message, sourceLocation(file, rule)); }
63+
let parsedSelectors = getParsedSelectors(block, rule, file);
5264

5365
// Iterate over the all selectors for this rule – one for each comma separated selector.
5466
parsedSelectors.forEach((iSel) => {
@@ -355,9 +367,9 @@ function assertBlockObject(block: Block, sel: CompoundSelector, rule: postcss.Ru
355367
}
356368
}
357369
return found;
358-
},
370+
},
359371
null,
360-
);
372+
);
361373

362374
// If no rules found in selector, we have a problem. Throw.
363375
if (!result) {

Diff for: ‎packages/css-blocks/src/TemplateAnalysis/TemplateAnalysis.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ import {
1919
} from "@opticss/util";
2020
import { IdentGenerator } from "opticss";
2121

22-
import { Block, OBJ_REF_SPLITTER, Style } from "../Block";
22+
import { Block, Style } from "../Block";
2323
import { BlockFactory } from "../BlockFactory";
2424
import { OptionsReader } from "../OptionsReader";
25-
import { CustomLocalScope } from "../util/LocalScope";
2625

2726
import { ElementAnalysis, SerializedElementAnalysis } from "./ElementAnalysis";
2827
import { StyleAnalysis } from "./StyleAnalysis";
@@ -338,10 +337,14 @@ export class TemplateAnalysis<K extends keyof TemplateTypes> implements StyleAna
338337
blockPromises.push(promise);
339338
});
340339
return Promise.all(blockPromises).then(values => {
341-
let localScope = new CustomLocalScope<Block, Style>(OBJ_REF_SPLITTER);
340+
341+
// Create a temporary block so we can take advantage of `Block.lookup`
342+
// to easily resolve all BlockPaths referenced in the serialized analysis.
343+
// TODO: We may want to abstract this so we're not making a temporary block.
344+
let localScope = new Block("analysis-block", "tmp");
342345
values.forEach(o => {
343346
analysis.blocks[o.name] = o.block;
344-
localScope.setSubScope(o.name, o.block);
347+
localScope.addBlockReference(o.name, o.block);
345348
});
346349
let objects = new Array<Style>();
347350
serializedAnalysis.stylesFound.forEach(s => {

Diff for: ‎packages/css-blocks/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export * from "./importing";
1111
export * from "./preprocessing";
1212
export * from "./TemplateAnalysis";
1313
export * from "./TemplateRewriter";
14-
export * from "./util/unionInto";
1514

1615
export {
1716
OptionsReader as PluginOptionsReader,

Diff for: ‎packages/css-blocks/src/query.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "opticss";
99
import postcss = require("postcss");
1010

11-
import { Style } from "./Block";
11+
import { Block, Style } from "./Block";
1212

1313
export interface Query {
1414
execute(container: postcss.Container): ClassifiedParsedSelectors;
@@ -24,8 +24,7 @@ export class QueryKeySelector implements Query {
2424
this.impl = new QueryKeySelectorImpl(new Element(tag, attrs));
2525
}
2626

27-
// Oooohhhh I don't like this! No part of Opticss should know about css-blocks data structures.
28-
execute(container: postcss.Container): ClassifiedParsedSelectors {
29-
return this.impl.execute(container);
27+
execute(container: postcss.Container, block?: Block): ClassifiedParsedSelectors {
28+
return this.impl.execute(container, block);
3029
}
3130
}

Diff for: ‎packages/css-blocks/src/util/LocalScope.ts

-123
This file was deleted.

Diff for: ‎packages/css-blocks/test/Block/BlockTree/block-tree-test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class TestSource extends Inheritable<
2424
> {
2525
protected newChild(name: string) { return new TestNode(name, this); }
2626
lookup(): undefined { return undefined; }
27+
setBase(base: TestSource) {
28+
this._base = base;
29+
}
2730
newChildNode: RootNode["newChild"] =
2831
(name: string) => this.newChild(name)
2932

Diff for: ‎packages/glimmer-templates/test/classnames-helper-test.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ describe("Classnames Helper", () => {
119119
it("generates an ast fragment for a state group", () => {
120120
let b = new Block("test", "test");
121121
let r = b.rootClass;
122-
let red = r.ensureSubState("theme", "red");
123-
let orange = r.ensureSubState("theme", "orange");
124-
let blue = r.ensureSubState("theme", "blue");
122+
let red = r.ensureState("theme", "red");
123+
let orange = r.ensureState("theme", "orange");
124+
let blue = r.ensureState("theme", "blue");
125125

126126
let inputs = [r, red, orange, blue];
127127
let rewrite = new IndexedClassMapping(inputs, [], { });
@@ -137,9 +137,9 @@ describe("Classnames Helper", () => {
137137
it("generates an ast fragment for a dependent state group", () => {
138138
let b = new Block("test", "test");
139139
let r = b.rootClass;
140-
let red = r.ensureSubState("theme", "red");
141-
let orange = r.ensureSubState("theme", "orange");
142-
let blue = r.ensureSubState("theme", "blue");
140+
let red = r.ensureState("theme", "red");
141+
let orange = r.ensureState("theme", "orange");
142+
let blue = r.ensureState("theme", "blue");
143143

144144
let inputs = [r, red, orange, blue];
145145
let rewrite = new IndexedClassMapping(inputs, [], { });
@@ -302,9 +302,9 @@ describe("Classnames Helper", () => {
302302
it("dependent state group is allowed when class is set", () => {
303303
let b = new Block("test", "test");
304304
let r = b.rootClass;
305-
let red = r.ensureSubState("theme", "red");
306-
let orange = r.ensureSubState("theme", "orange");
307-
let blue = r.ensureSubState("theme", "blue");
305+
let red = r.ensureState("theme", "red");
306+
let orange = r.ensureState("theme", "orange");
307+
let blue = r.ensureState("theme", "blue");
308308

309309
let inputs = [r, red, orange, blue];
310310
let rewrite = new IndexedClassMapping(inputs, [], {
@@ -329,9 +329,9 @@ describe("Classnames Helper", () => {
329329
it("dependent state group is disabled when class is not set", () => {
330330
let b = new Block("test", "test");
331331
let r = b.rootClass;
332-
let red = r.ensureSubState("theme", "red");
333-
let orange = r.ensureSubState("theme", "orange");
334-
let blue = r.ensureSubState("theme", "blue");
332+
let red = r.ensureState("theme", "red");
333+
let orange = r.ensureState("theme", "orange");
334+
let blue = r.ensureState("theme", "blue");
335335

336336
let inputs = [r, red, orange, blue];
337337
let rewrite = new IndexedClassMapping(inputs, [], {
@@ -356,9 +356,9 @@ describe("Classnames Helper", () => {
356356
it("dependent state group is unset when falsy", () => {
357357
let b = new Block("test", "test");
358358
let r = b.rootClass;
359-
let red = r.ensureSubState("theme", "red");
360-
let orange = r.ensureSubState("theme", "orange");
361-
let blue = r.ensureSubState("theme", "blue");
359+
let red = r.ensureState("theme", "red");
360+
let orange = r.ensureState("theme", "orange");
361+
let blue = r.ensureState("theme", "blue");
362362

363363
let inputs = [r, red, orange, blue];
364364
let rewrite = new IndexedClassMapping(inputs, [], {
@@ -383,9 +383,9 @@ describe("Classnames Helper", () => {
383383
it("dependent state group errors when falsy", () => {
384384
let b = new Block("test", "test");
385385
let r = b.rootClass;
386-
let red = r.ensureSubState("theme", "red");
387-
let orange = r.ensureSubState("theme", "orange");
388-
let blue = r.ensureSubState("theme", "blue");
386+
let red = r.ensureState("theme", "red");
387+
let orange = r.ensureState("theme", "orange");
388+
let blue = r.ensureState("theme", "blue");
389389

390390
let inputs = [r, red, orange, blue];
391391
let rewrite = new IndexedClassMapping(inputs, [], {
@@ -412,9 +412,9 @@ describe("Classnames Helper", () => {
412412
let c1 = b.ensureClass("class-1");
413413
let c2 = b.ensureClass("class-2");
414414
let c3 = b.ensureClass("class-3");
415-
let red = r.ensureSubState("theme", "red");
416-
let orange = r.ensureSubState("theme", "orange");
417-
let blue = r.ensureSubState("theme", "blue");
415+
let red = r.ensureState("theme", "red");
416+
let orange = r.ensureState("theme", "orange");
417+
let blue = r.ensureState("theme", "blue");
418418

419419
let element = new ElementAnalysis<BooleanAST, StringAST, TernaryAST>({start: POSITION_UNKNOWN});
420420
element.addDynamicClasses({

Diff for: ‎packages/jsx/src/transformer/webpackLoader.ts

+4
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ export function CSSBlocksWebpackAdapter(this: any, source: any, map: any): void
8080
});
8181

8282
}
83+
84+
// Webpack expects the default export of loaders to be the loader itself.
85+
// tslint:disable-next-line:no-default-export
86+
export default CSSBlocksWebpackAdapter;

0 commit comments

Comments
 (0)
Please sign in to comment.