Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 509021 of stylesheet/style

  • Revision slug: Mozilla/Add-ons/SDK/Low-Level_APIs/stylesheet_style
  • Revision title: stylesheet/style
  • Revision id: 509021
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment

Revision Content

Experimental

Modify styles using stylesheet files or CSS rules.

Globals

Constructors

Style(options)

The Style constructor creates an object that represents style modifications via stylesheet file(s) or/and CSS rules. Stylesheet file URL(s) are verified to be local to an add-on, while CSS rules are virified to be a string or array of strings.

The style created can be applied to a content by calling attach, and removed using detach. Those functions are part of content/mod module.

Parameters

options : object
Required options:

Name Type  
uri string,array

A string, or an array of strings, that represents local URI to stylesheet.

source string,array

A string, or an array of strings, that contains CSS rules. Those rules are applied after the rules in the stylesheet specified with uri options, if provided.

Optional options:

Name Type  
type string

The type of the sheet. It accepts the following values: "agent", "user" and "author". If not provided, the default value is "author".

Style

Properties

source

An array of strings that contains the CSS rule(s) specified in the constructor's option; null if no source option was given to the constructor. This property is read-only.

uri

An array of strings that contains the stylesheet local URI(s) specified in the constructor's option; null if no uri option was given to the constructor. This property is read-only.

type

The type of the sheet. If no type is provided in constructor's option, it returns the default value, "author". This property is read-only.

Revision Source

<div class="note">
 <p>Experimental</p>
</div>
<p><span class="seoSummary">Modify styles using stylesheet files or CSS rules.</span></p>
<h2>Globals</h2>
<h3>Constructors</h3>
<h4 class="addon-sdk-api-name"><code>Style(options)</code></h4>
<p>The Style constructor creates an object that represents style modifications via stylesheet file(s) or/and CSS rules. Stylesheet file URL(s) are verified to be local to an add-on, while CSS rules are virified to be a string or array of strings.</p>
<p>The style created can be applied to a content by calling <code>attach</code>, and removed using <code>detach</code>. Those functions are part of <a href="modules/sdk/content/mod.html">content/mod</a> module.</p>
<h5>Parameters</h5>
<p><strong>options : object</strong><br />
 Required options:</p>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Name</th>
   <th scope="col">Type</th>
   <th scope="col">&nbsp;</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>uri</td>
   <td>string,array</td>
   <td>
    <p>A string, or an array of strings, that represents local URI to stylesheet.</p>
   </td>
  </tr>
  <tr>
   <td>source</td>
   <td>string,array</td>
   <td>
    <p>A string, or an array of strings, that contains CSS rules. Those rules are applied after the rules in the stylesheet specified with <code>uri</code> options, if provided.</p>
   </td>
  </tr>
 </tbody>
</table>
<p>Optional options:</p>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Name</th>
   <th scope="col">Type</th>
   <th scope="col">&nbsp;</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>type</td>
   <td>string</td>
   <td>
    <p>The type of the sheet. It accepts the following values: <code>"agent"</code>, <code>"user"</code> and <code>"author"</code>. If not provided, the default value is <code>"author"</code>.</p>
   </td>
  </tr>
 </tbody>
</table>
<h2>Style</h2>
<h3>Properties</h3>
<h4 class="addon-sdk-api-name"><code>source</code></h4>
<p>An array of strings that contains the CSS rule(s) specified in the constructor's option; <code>null</code> if no <code>source</code> option was given to the constructor. This property is read-only.</p>
<h4 class="addon-sdk-api-name"><code>uri</code></h4>
<p>An array of strings that contains the stylesheet local URI(s) specified in the constructor's option; <code>null</code> if no <code>uri</code> option was given to the constructor. This property is read-only.</p>
<h4 class="addon-sdk-api-name"><code>type</code></h4>
<p>The type of the sheet. If no type is provided in constructor's option, it returns the default value, <code>"author"</code>. This property is read-only.</p>
Revert to this revision