Skip to content

Commit e6c5177

Browse files
Lodincalebdwilliams
authored andcommitted
feat: add CSSStyleSheet.prototype.media
1 parent ebbd780 commit e6c5177

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/ConstructedStyleSheet.ts

+11
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ defineProperty(proto, 'cssRules', {
219219
},
220220
});
221221

222+
defineProperty(proto, 'media', {
223+
configurable: true,
224+
enumerable: true,
225+
get: function media() {
226+
// CSSStyleSheet.prototype.media;
227+
checkInvocationCorrectness(this);
228+
229+
return $basicStyleElement.get(this)!.sheet!.media;
230+
},
231+
});
232+
222233
cssStyleSheetMethods.forEach((method) => {
223234
proto[method] = function () {
224235
const self = this;

test/polyfill.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('Constructible Style Sheets polyfill', () => {
5151
describe('basic', () => {
5252
it('has replace and replaceSync methods', () => {
5353
expect(sheet.cssRules).toBeDefined();
54+
expect(sheet.media).toBeDefined();
5455
expect(sheet.replace).toBeDefined();
5556
expect(sheet.replaceSync).toBeDefined();
5657
});
@@ -99,6 +100,12 @@ describe('Constructible Style Sheets polyfill', () => {
99100
illegalPattern,
100101
);
101102
});
103+
104+
it('media', () => {
105+
expect(() => CSSStyleSheet.prototype.media).toThrowError(
106+
illegalPattern,
107+
);
108+
});
102109
});
103110
});
104111

0 commit comments

Comments
 (0)