Skip to content

Commit

Permalink
Split -prefix-free into StyleFix and -prefix-free (still in same file…
Browse files Browse the repository at this point in the history
…), made value replacement more robust
  • Loading branch information
Lea Verou committed Oct 28, 2011
1 parent c836722 commit c433b8a
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 144 deletions.
53 changes: 38 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,42 @@ It works behind the scenes, adding the current browser’s prefix to any CSS cod
## API Documentation
Note: To use -prefix-free you don't need to write any JS code, just to include prefixfree.js in your page. The following is meant mostly for plugin authors.

-prefix-free creates 2 global variables: `StyleFix` and `PrefixFree`. StyleFix is a framework for building various CSS fixers and -prefix-free depends on it. Currently, StyleFix is bundled with -prefix-free and only available this way, but it might eventually get split to a separate project, with separate documentation.

## StyleFix API Documentation

### Properties
StyleFix.fixers
An array of the current callbacks.

### Functions
StyleFix.register(callback)
Adds `callback` to the queue of functions that will be called when fixing CSS code. `callback` will be called with the following parameters:

* **css** (String): The CSS code that is being processed,
* **raw** (Boolean): Whether the CSS code can contain rules etc or it's just a bunch of declarations (such as the ones found in the `style` attribute),
* **element** (HTMLElement): The node that the CSS code came from (such as a `<link>` element, a `<style>` element or any element with a `style` attribute)

and it should return the fixed CSS code.

StyleFix.link(linkElement)

Processes a `<link rel="stylesheet">` element and converts it to a `<style>` element with fixed code. Relative URLs will be converted.

StyleFix.styleElement(styleElement)

Fixes code inside a `<style>` element.

StyleFix.styleAttribute(element)

Fixes code inside the `style` attribute of an element. Will not work in IE and Firefox &lt; 3.6 due to a bug those have with `getAttribute('style')`: In IE invalid values of valid properties will be dropped, and in Firefox &lt; 3.6 anything invalid will be dropped.

StyleFix.camelCase(str)
StyleFix.deCamelCase(str)
Utility methods that convert a string to camelCase and back.

## -prefix-free API Documentation

### Properties
PrefixFree.prefix
The detected prefix of the current browser (like `'-moz-'` or `'-webkit-'`)
Expand All @@ -23,23 +59,10 @@ The detected prefix of the current browser in camelCase format (like `'Moz'` or
PrefixFree.atrules
Properties/functions/keywords/etc that are **only** available with a prefix in the current browser.

### Methods
### Functions
PrefixFree.prefixCSS(code [, raw])
Prefixes the properties and values in the code passed with the prefix of the current browser, only when needed. If the second parameter is truthy, it also prefixes selectors and @-rules. This is the most useful method in -prefix-free.

PrefixFree.process.link(linkElement)
Processes a `<link rel="stylesheet">` element and converts it to a `<style>` element with prefixed code.

PrefixFree.process.styleElement(styleElement)
Prefixes code inside a `<style>` element.

PrefixFree.process.styleAttribute(element)
Prefixes code inside the `style` attribute of an element. Will not work in IE and Firefox 3.6- due to a bug those have with `getAttribute('style')`.

PrefixFree.prefixSelector(selector)
PrefixFree.prefixProperty(property)
Prefixes the passed selector or property **even when it's supported prefix-less**. These are more internal methods and I assume they won't be too useful in general.

PrefixFree.camelCase(str)
PrefixFree.deCamelCase(str)
Utility methods that convert a string to camelCase and back.
Prefixes the passed selector or property **even when it's supported prefix-less**. These are more internal methods and I assume they won't be too useful in general.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1>-prefix-free</h1>
<h2>Break free from CSS prefix hell!</h2>
</hgroup>

<a href="https://raw.github.com/LeaVerou/prefixfree/master/prefixfree.min.js" class="download" title="Click to download">Only <strong>4KB</strong> minified</a>
<a href="https://raw.github.com/LeaVerou/prefixfree/master/prefixfree.min.js" class="download" title="Click to download">Only <strong>2KB</strong> gzipped</a>
<a href="https://github.com/LeaVerou/prefixfree" target="_blank" class="github-ribbon"><img src="https://a248.e.akamai.net/assets.github.com/img/71eeaab9d563c2b3c590319b398dd35683265e85/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub"></a>

<p id="wtf">
Expand Down
Loading

0 comments on commit c433b8a

Please sign in to comment.