summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 23:45:03 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 23:45:03 +0000
commite22ddddb19c659dce909396cb2320979cbedc5d2 (patch)
treefbd2dbc1ceb0747dba2061ea89d96f1ce6a42149
parent04d6d58fec6d747bfe5e09b5b2dbaf6e48bb747c (diff)
downloadchromium_src-e22ddddb19c659dce909396cb2320979cbedc5d2.zip
chromium_src-e22ddddb19c659dce909396cb2320979cbedc5d2.tar.gz
chromium_src-e22ddddb19c659dce909396cb2320979cbedc5d2.tar.bz2
Remove JS emulation of HTMLElement classList now that WebKit supports it natively.
BUG=None TEST=NTP, Bookmarks manager, settings should all continue to work. Review URL: http://codereview.chromium.org/3521015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61586 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/menu.html2
-rw-r--r--chrome/browser/resources/new_new_tab.html1
-rw-r--r--chrome/browser/resources/ntp/most_visited.js1
-rw-r--r--chrome/browser/resources/options.html1
-rw-r--r--chrome/browser/resources/shared/js/class_list.js94
-rw-r--r--chrome/browser/resources/shared/js/class_list_test.html91
-rw-r--r--chrome/browser/resources/shared_resources.grd2
7 files changed, 0 insertions, 192 deletions
diff --git a/chrome/browser/resources/menu.html b/chrome/browser/resources/menu.html
index 4cea45c..8015bdf 100644
--- a/chrome/browser/resources/menu.html
+++ b/chrome/browser/resources/menu.html
@@ -3,7 +3,6 @@
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="menu.css"/>
- <script src="shared/js/class_list.js"></script>
<script src="menu.js"></script>
</head>
<body>
@@ -13,4 +12,3 @@
</script>
</body>
</html>
-
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 8700500..ab47110 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -236,7 +236,6 @@ if ('mode' in hashParams) {
i18nTemplate.process(document, templateData);
</script>
<script src="shared/js/local_strings.js"></script>
-<script src="shared/js/class_list.js"></script>
<script src="shared/js/parse_html_subset.js"></script>
<script src="shared/js/cr.js"></script>
diff --git a/chrome/browser/resources/ntp/most_visited.js b/chrome/browser/resources/ntp/most_visited.js
index 72557ac..1f8b740 100644
--- a/chrome/browser/resources/ntp/most_visited.js
+++ b/chrome/browser/resources/ntp/most_visited.js
@@ -3,7 +3,6 @@
// found in the LICENSE file.
// Dependencies that we should remove/formalize:
-// ../shared/js/class_list.js
// util.js
//
// afterTransition
diff --git a/chrome/browser/resources/options.html b/chrome/browser/resources/options.html
index dc3e321..d54b1af 100644
--- a/chrome/browser/resources/options.html
+++ b/chrome/browser/resources/options.html
@@ -40,7 +40,6 @@
<script src="chrome://resources/css/tree.css.js"></script>
-<script src="chrome://resources/js/class_list.js"></script>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/event_target.js"></script>
<script src="chrome://resources/js/cr/ui.js"></script>
diff --git a/chrome/browser/resources/shared/js/class_list.js b/chrome/browser/resources/shared/js/class_list.js
deleted file mode 100644
index edfd98f..0000000
--- a/chrome/browser/resources/shared/js/class_list.js
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview This implements the HTML5 HTMLElement classList property.
- */
-
-// TODO(arv): Remove this when classList is available in WebKit.
-// https://bugs.webkit.org/show_bug.cgi?id=20709
-
-if (typeof document.createElement('div').classList == 'undefined') {
-
-function DOMTokenList(el) {
- this.el_ = el;
-}
-
-(function() {
-
- var re = /\s+/;
-
- function split(el) {
- var cn = el.className.replace(/^\s+|\s$/g, '');
- if (cn == '')
- return [];
- return cn.split(re);
- }
-
- function DOMException_(code) {
- this.code = code;
- }
- DOMException_.prototype = DOMException.prototype;
-
- function assertValidToken(s) {
- if (s == '')
- throw new DOMException_(DOMException.SYNTAX_ERR);
- if (re.test(s))
- throw new DOMException_(DOMException.INVALID_CHARACTER_ERR);
- }
-
- DOMTokenList.prototype = {
- contains: function(token) {
- assertValidToken(token);
- return split(this.el_).indexOf(token) >= 0;
- },
- add: function(token) {
- assertValidToken(token);
- if (this.contains(token))
- return;
- var cn = this.el_.className;
- this.el_.className += (cn == '' || re.test(cn.slice(-1)) ? '' : ' ') +
- token;
- },
- remove: function(token) {
- assertValidToken(token);
- var names = split(this.el_);
- var s = [];
- for (var i = 0; i < names.length; i++) {
- if (names[i] != token)
- s.push(names[i])
- }
- this.el_.className = s.join(' ');
- },
- toggle: function(token) {
- assertValidToken(token);
- if (this.contains(token)) {
- this.remove(token);
- return false;
- } else {
- this.add(token);
- return true;
- }
- },
- get length() {
- return split(this.el_).length;
- },
- item: function(index) {
- return split(this.el_)[index];
- }
- };
-
-})();
-
-HTMLElement.prototype.__defineGetter__('classList', function() {
- var tl = new DOMTokenList(this);
- // Override so that we reuse the same DOMTokenList and so that
- // el.classList == el.classList
- this.__defineGetter__('classList', function() {
- return tl;
- });
- return tl;
-});
-
-} // if
diff --git a/chrome/browser/resources/shared/js/class_list_test.html b/chrome/browser/resources/shared/js/class_list_test.html
deleted file mode 100644
index c84b8ce..0000000
--- a/chrome/browser/resources/shared/js/class_list_test.html
+++ /dev/null
@@ -1,91 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<title></title>
-<script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
-<script src="class_list.js"></script>
-<script>
-
-goog.require('goog.testing.jsunit');
-
-</script>
-</head>
-<body>
-
-<script>
-
-var el = document.body;
-
-function testLength() {
- el.className = 'a b';
- assertEquals(2, el.classList.length);
- el.setAttribute('class', 'a b c');
- assertEquals(3, el.classList.length);
-}
-
-function testItem() {
- el.className = 'a b';
- assertEquals('a', el.classList.item(0));
- assertEquals('b', el.classList.item(1));
- el.setAttribute('class', 'a b c');
- assertEquals('a', el.classList.item(0));
- assertEquals('b', el.classList.item(1));
- assertEquals('c', el.classList.item(2));
-}
-
-function testContains() {
- el.className = 'a b';
- assertTrue(el.classList.contains('a'));
- assertTrue(el.classList.contains('b'));
- assertFalse(el.classList.contains('c'));
-
- assertEquals('b', el.classList.item(1));
- el.setAttribute('class', 'a b c');
- assertTrue(el.classList.contains('a'));
- assertTrue(el.classList.contains('b'));
- assertTrue(el.classList.contains('c'));
-}
-
-function testToken() {
- assertThrows(function() {
- el.classList.add('');
- });
- assertThrows(function() {
- el.classList.add(' ');
- });
- assertThrows(function() {
- el.classList.add('\t');
- });
- assertThrows(function() {
- el.classList.add('\n');
- });
-}
-
-function testAdd() {
- el.className = 'a b';
- el.classList.add('a');
- assertEquals('a b', el.className);
- el.classList.add('c');
- assertEquals('a b c', el.className);
-}
-
-function testRemove() {
- el.className = 'a b';
- el.classList.remove('b');
- assertEquals('a', el.className);
- el.classList.remove('a');
- assertEquals('', el.className);
-}
-
-function testToggle() {
- el.className = 'a b';
- assertFalse(el.classList.toggle('a'));
- assertEquals('b', el.className);
- assertTrue(el.classList.toggle('a'));
- assertEquals('b a', el.className);
-}
-
-</script>
-
-</body>
-</html>
diff --git a/chrome/browser/resources/shared_resources.grd b/chrome/browser/resources/shared_resources.grd
index 2d79a05..18dc93a 100644
--- a/chrome/browser/resources/shared_resources.grd
+++ b/chrome/browser/resources/shared_resources.grd
@@ -24,8 +24,6 @@ without changes to the corresponding grd file. paaaae -->
file="shared/css/tree.css" type="BINDATA" />
<include name="IDR_SHARED_CSS_TREE_JS"
file="shared/css/tree.css.js" type="BINDATA" />
- <include name="IDR_SHARED_JS_CLASS_LIST"
- file="shared/js/class_list.js" type="BINDATA" />
<include name="IDR_SHARED_JS_CR"
file="shared/js/cr.js" type="BINDATA" />
<include name="IDR_SHARED_JS_CR_EVENT_TARGET"