don't fail if no classList support

This commit is contained in:
Jacob MacDonald
2015-02-02 10:50:16 -08:00
parent 6c3cc38e67
commit 973ffca84f
3 changed files with 14 additions and 0 deletions

View File

@@ -14,6 +14,12 @@
(function(scope) {
'use strict';
if (!window.DOMTokenList) {
console.warn('Missing DOMTokenList prototype, please include a ' +
'compatible classList polyfill such as http://goo.gl/uTcepH.');
return;
}
var unsafeUnwrap = scope.unsafeUnwrap;
var enqueueMutation = scope.enqueueMutation;

View File

@@ -103,6 +103,7 @@
var list = classListTable.get(this);
if (!list) {
list = unsafeUnwrap(this).classList;
if (!list) return;
list.ownerElement_ = this;
classListTable.set(this, list);
}

View File

@@ -9,6 +9,13 @@
*/
suite('DOMTokenList', function() {
if (!window.DOMTokenList) {
test('classList returns undefined if not supported', function() {
var div = document.createElement('div');
assert.isUndefined(div.classList);
});
return;
}
test('instanceof', function() {
var div = document.createElement('div');