• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2@license
3Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7Code distributed by Google as part of the polymer project is also
8subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9*/
10
11'use strict';
12
13import {StyleNode} from './css-parse.js'; // eslint-disable-line no-unused-vars
14
15/** @const {string} */
16const infoKey = '__styleInfo';
17
18export default class StyleInfo {
19  /**
20   * @param {Element} node
21   * @return {StyleInfo}
22   */
23  static get(node) {
24    if (node) {
25      return node[infoKey];
26    } else {
27      return null;
28    }
29  }
30  /**
31   * @param {!Element} node
32   * @param {StyleInfo} styleInfo
33   * @return {StyleInfo}
34   */
35  static set(node, styleInfo) {
36    node[infoKey] = styleInfo;
37    return styleInfo;
38  }
39  /**
40   * @param {StyleNode} ast
41   * @param {Node=} placeholder
42   * @param {Array<string>=} ownStylePropertyNames
43   * @param {string=} elementName
44   * @param {string=} typeExtension
45   * @param {string=} cssBuild
46   */
47  constructor(ast, placeholder, ownStylePropertyNames, elementName, typeExtension, cssBuild) {
48    /** @type {StyleNode} */
49    this.styleRules = ast || null;
50    /** @type {Node} */
51    this.placeholder = placeholder || null;
52    /** @type {!Array<string>} */
53    this.ownStylePropertyNames = ownStylePropertyNames || [];
54    /** @type {Array<Object>} */
55    this.overrideStyleProperties = null;
56    /** @type {string} */
57    this.elementName = elementName || '';
58    /** @type {string} */
59    this.cssBuild = cssBuild || '';
60    /** @type {string} */
61    this.typeExtension = typeExtension || '';
62    /** @type {Object<string, string>} */
63    this.styleProperties = null;
64    /** @type {?string} */
65    this.scopeSelector = null;
66    /** @type {HTMLStyleElement} */
67    this.customStyle = null;
68  }
69  _getStyleRules() {
70    return this.styleRules;
71  }
72}
73
74/* eslint-disable-next-line no-self-assign */
75StyleInfo.prototype['_getStyleRules'] = StyleInfo.prototype._getStyleRules;
76