1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// A drop-in replacement for one method that we could use from Closure.
6
7goog.provide('goog.style');
8
9/**
10 * Creates a style sheet in the document containing the passed rules.
11 * A simplified version that does not take an optional node parameter.
12 * @param {string} rules
13 */
14goog.style.installStyles = function(rules) {
15  try {
16    var ss = document.createElement('style');
17    ss.setAttribute('type', 'text/css');
18    if (ss.styleSheet) {
19      ss.styleSheet.cssText = rules;
20    } else {
21      ss.appendChild(document.createTextNode(rules));
22    }
23    var h = document.getElementsByTagName('head')[0];
24    var firstChild = h.firstChild;
25    h.insertBefore(ss, firstChild);
26  } catch (e) {
27    // squelch
28  }
29};
30