flinker-dom 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,11 +75,16 @@ export class StyleSheetProcessor {
75
75
  constructor(styleSheet) {
76
76
  this.hash = new Map();
77
77
  this.list = Array.of();
78
- this.list.push(new NoPseudoClass(styleSheet));
79
- this.list.push(new HoverPseudoClass(styleSheet));
80
- this.list.push(new FocusPseudoClass(styleSheet));
81
- this.list.push(new PlaceholderPseudoClass(styleSheet));
82
- this.list.forEach(c => this.hash.set(c.type, c));
78
+ ['none', 'hover', 'focus', 'placeholder', 'active', 'visited', 'link'].forEach(t => {
79
+ switch (t) {
80
+ case ('hover'):
81
+ this.hash.set('hover', new HoverPseudoClass(styleSheet));
82
+ break;
83
+ default:
84
+ this.hash.set(t, new PseudoClass(t, styleSheet));
85
+ break;
86
+ }
87
+ });
83
88
  }
84
89
  setValue(to, key, value, priority, appendToClassName = true) {
85
90
  const pseudoClass = this.hash.get(to);
@@ -108,7 +113,10 @@ export class PseudoClass {
108
113
  this.hashSum = '';
109
114
  }
110
115
  insertRule(className, tag) {
111
- throw new Error('Abstract method PseudoClass:insertRule should be overwritten');
116
+ if (this.style) {
117
+ const rule = tag + '.' + className + (this.type === 'none' ? '' : ':' + this.type) + '{' + this.style + '}';
118
+ this.styleSheet.insertRule(rule);
119
+ }
112
120
  }
113
121
  setValue(key, value, priority, appendToClassName = true) {
114
122
  if (value === undefined)
@@ -129,17 +137,6 @@ export class PseudoClass {
129
137
  this.style = '';
130
138
  }
131
139
  }
132
- class NoPseudoClass extends PseudoClass {
133
- constructor(styleSheet) {
134
- super('none', styleSheet);
135
- }
136
- insertRule(className, tag) {
137
- if (this.style) {
138
- const rule = tag + '.' + className + '{' + this.style + '}';
139
- this.styleSheet.insertRule(rule);
140
- }
141
- }
142
- }
143
140
  class HoverPseudoClass extends PseudoClass {
144
141
  constructor(styleSheet) {
145
142
  super('hover', styleSheet);
@@ -152,24 +149,3 @@ class HoverPseudoClass extends PseudoClass {
152
149
  }
153
150
  }
154
151
  }
155
- class FocusPseudoClass extends PseudoClass {
156
- constructor(styleSheet) {
157
- super('focus', styleSheet);
158
- }
159
- insertRule(className, tag) {
160
- if (this.style) {
161
- const rule = tag + '.' + className + ':focus{' + this.style + '}';
162
- this.styleSheet.insertRule(rule);
163
- }
164
- }
165
- }
166
- class PlaceholderPseudoClass extends PseudoClass {
167
- constructor(styleSheet) {
168
- super('placeholder', styleSheet);
169
- }
170
- insertRule(className, tag) {
171
- if (this.style) {
172
- this.styleSheet.insertRule(tag + '.' + className + '::placeholder{' + this.style + '}');
173
- }
174
- }
175
- }
@@ -8,7 +8,7 @@ export declare class StyleSheetProcessor {
8
8
  insertRule(className: string, tag: string): void;
9
9
  clearValues(): void;
10
10
  }
11
- export type PseudoClassType = 'none' | 'hover' | 'focus' | 'placeholder';
11
+ export type PseudoClassType = 'none' | 'hover' | 'focus' | 'placeholder' | 'active' | 'visited' | 'link';
12
12
  export declare class PseudoClass {
13
13
  readonly type: PseudoClassType;
14
14
  readonly styleSheet: CSSStyleSheet;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flinker-dom",
3
3
  "description": "Free TypeScript library for writing frontend apps",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Dittner/FlinkerDOM.git"