Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: wbamberg <[email protected]>
  • Loading branch information
estelle and wbamberg authored Dec 16, 2024
1 parent 329f4f6 commit 7e3ae3f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions files/en-us/web/api/medialist/tostring/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ A string; a space-separated list of media values.
## Examples

```js
const SS = document.styleSheets[0]; // the document's first stylesheet
const ML = SS.media; // the mediaList of the stylesheet
const styleSheets = document.styleSheets[0]; // the document's first stylesheet
const mediaList = styleSheets.media; // the mediaList of the stylesheet

// set the `media` text to a media query value
ss.mediaText = "SCREEN AND (140PX <= WIDTH <= 380PX)";
styleSheets.mediaText = "SCREEN AND (140PX <= WIDTH <= 380PX)";

// add a second media value
ML.appendMedium("SCREEN AND (MAX-HEIGHT: 400PX) AND (ORIENTATION: LANDSCAPE))");
// erroniously, add a media query twice
ML.appendMedium("SCREEN AND (MAX-HEIGHT: 400PX) AND (ORIENTATION: LANDSCAPE))");
console.log(ML.toString()); // "screen and (140px <= width <= 380px), screen and (max-height: 400px) and (orientation: landscape)"
```
mediaList.appendMedium("SCREEN AND (MAX-HEIGHT: 400PX) AND (ORIENTATION: LANDSCAPE))");

Media list values are lowercase. When stringified, the values are separated by a comma followed by a space.
// erroneously, add the same media query again
mediaList.appendMedium("SCREEN AND (MAX-HEIGHT: 400PX) AND (ORIENTATION: LANDSCAPE))");

console.log(mediaList.toString());
// "screen and (140px <= width <= 380px), screen and (max-height: 400px) and (orientation: landscape)"
```

## Specifications

Expand Down

0 comments on commit 7e3ae3f

Please sign in to comment.