Socket
Socket
Sign inDemoInstall

postcss-custom-media

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-custom-media - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

8

CHANGELOG.md

@@ -0,1 +1,9 @@

# 4.0.0 - 2015-05-17
- Changed: warning messages are now sent via postcss messages api (^4.1.0)
- Added: automatic custom media `--` prefixing
([#11](https://github.com/postcss/postcss-custom-media/issues/11))
- Added: `preserve` allows you to preserve custom media query defintions
- Added: `appendExtensions` allows you (when `preserve` is truthy) to append your extensions as media queries
# 3.0.0 - 2015-01-29

@@ -2,0 +10,0 @@

66

index.js

@@ -1,23 +0,23 @@

/**
* Module dependencies
*/
var helpers = require("postcss-message-helpers")
var postcss = require("postcss")
/**
* Constants.
*/
var EXTENSION_RE = /\(\s*(--[\w-]+)\s*\)/g
/**
* Expose the plugin.
*/
module.exports = customMedia
/**
/*
* read & replace custom media queries by standard media queries
*/
function customMedia(options) {
return function(styles) {
return function(styles, result) {
options = options || {}
var extensions = options.extensions || {}
var extensions = {}
if (options.extensions) {
Object.keys(options.extensions).forEach(function(name) {
var val = options.extensions[name]
if (name.slice(0, 2) !== "--") {
name = "--" + name
}
extensions[name] = val
})
}
var appendExtensions = options.appendExtensions
var preserve = options.preserve
var map = {}

@@ -37,8 +37,10 @@ var toRemove = []

toRemove.push(rule)
if (!preserve) {
toRemove.push(rule)
}
})
// apply js-defined media queries
Object.keys(extensions).forEach(function(extension) {
map[extension] = extensions[extension]
Object.keys(extensions).forEach(function(name) {
map[name] = extensions[name]
})

@@ -57,3 +59,7 @@

console.warn(helpers.message("missing @custom-media definition for '" + name + "'. The entire rule has been removed from the output.", rule.source))
result.warn(
"Missing @custom-media definition for '" + name +
"'. The entire rule has been removed from the output.",
{node: rule}
)
toRemove.push(rule)

@@ -63,5 +69,25 @@ })

if (appendExtensions) {
var names = Object.keys(map)
if (names.length) {
names.forEach(function(name) {
var atRule = postcss.atRule({
name: "custom-media",
afterName: " ",
params: name + " " + map[name],
})
styles.append(atRule)
})
styles.semicolon = true
styles.after = "\n"
}
}
// remove @custom-media
toRemove.forEach(function(rule) { rule.removeSelf() })
toRemove.forEach(function(rule) {
rule.removeSelf()
})
}
}
module.exports = postcss.plugin("postcss-custom-media", customMedia)
{
"name": "postcss-custom-media",
"version": "3.0.0",
"version": "4.0.0",
"description": " PostCSS plugin to transform W3C CSS Custom Media Queries to more compatible CSS",

@@ -24,14 +24,11 @@ "keywords": [

"dependencies": {
"postcss-message-helpers": "^2.0.0"
"postcss": "^4.1.4"
},
"devDependencies": {
"jscs": "^1.6.2",
"jshint": "^2.5.6",
"postcss": "^4.0.2",
"tape": "^3.0.0"
"eslint": "^0.23.0",
"tape": "^4.0.0"
},
"scripts": {
"lint": "jscs *.js **/*.js && jshint . --exclude-path .gitignore",
"test": "npm run lint && tape test"
"test": "eslint . && tape test"
}
}

@@ -7,3 +7,5 @@ # postcss-custom-media [![Build Status](https://travis-ci.org/postcss/postcss-custom-media.png)](https://travis-ci.org/postcss/postcss-custom-media)

$ npm install postcss-custom-media
```console
$ npm install postcss-custom-media
```

@@ -49,19 +51,26 @@ ## Usage

#### `extensions` (default: `{}`)
#### `extensions`
Allows you to pass an object to define the `<media-query-list>` for each `<extension-name>`. These definitions will override any that exist in the CSS.
(default: `{}`)
---
Allows you to pass an object to define the `<media-query-list>` for each
`<extension-name>`. These definitions will override any that exist in the CSS.
## Contributing
#### `preserve`
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
(default: `false`)
$ git clone https://github.com/postcss/postcss-custom-media.git
$ git checkout -b patch-1
$ npm install
$ npm test
Allows you to preserve custom media query definitions in output.
#### `appendExtensions`
(default: `false`)
**This option only works if `preserve` is truthy**.
Allows you to append your extensions at end of your CSS.
---
## [Changelog](CHANGELOG.md)
## [License](LICENSE)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc