This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
249 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2013 The Polymer Authors. All rights reserved. | ||
// Use of this source code is goverened by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
(function(scope) { | ||
'use strict'; | ||
|
||
var HTMLMediaElement = scope.wrappers.HTMLMediaElement; | ||
var registerWrapper = scope.registerWrapper; | ||
var unwrap = scope.unwrap; | ||
var rewrap = scope.rewrap; | ||
|
||
var OriginalHTMLAudioElement = window.HTMLAudioElement; | ||
|
||
function HTMLAudioElement(node) { | ||
HTMLMediaElement.call(this, node); | ||
} | ||
HTMLAudioElement.prototype = Object.create(HTMLMediaElement.prototype); | ||
|
||
registerWrapper(OriginalHTMLAudioElement, HTMLAudioElement, | ||
document.createElement('audio')); | ||
|
||
function Audio(src) { | ||
if (!(this instanceof Audio)) { | ||
throw new TypeError( | ||
'DOM object constructor cannot be called as a function.'); | ||
} | ||
|
||
var node = unwrap(document.createElement('audio')); | ||
HTMLMediaElement.call(this, node); | ||
rewrap(node, this); | ||
|
||
node.setAttribute('preload', 'auto'); | ||
if (src !== undefined) | ||
node.setAttribute('src', src); | ||
} | ||
|
||
Audio.prototype = HTMLAudioElement.prototype; | ||
|
||
scope.wrappers.HTMLAudioElement = HTMLAudioElement; | ||
scope.wrappers.Audio = Audio; | ||
})(this.ShadowDOMPolyfill); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2013 The Polymer Authors. All rights reserved. | ||
// Use of this source code is goverened by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
(function(scope) { | ||
'use strict'; | ||
|
||
var HTMLElement = scope.wrappers.HTMLElement; | ||
var registerWrapper = scope.registerWrapper; | ||
|
||
var OriginalHTMLMediaElement = window.HTMLMediaElement; | ||
|
||
function HTMLMediaElement(node) { | ||
HTMLElement.call(this, node); | ||
} | ||
HTMLMediaElement.prototype = Object.create(HTMLElement.prototype); | ||
|
||
registerWrapper(OriginalHTMLMediaElement, HTMLMediaElement, | ||
document.createElement('audio')); | ||
|
||
scope.wrappers.HTMLMediaElement = HTMLMediaElement; | ||
})(this.ShadowDOMPolyfill); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2013 The Polymer Authors. All rights reserved. | ||
// Use of this source code is goverened by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
(function(scope) { | ||
'use strict'; | ||
|
||
var HTMLElement = scope.wrappers.HTMLElement; | ||
var mixin = scope.mixin; | ||
var registerWrapper = scope.registerWrapper; | ||
var rewrap = scope.rewrap; | ||
var unwrap = scope.unwrap; | ||
var wrap = scope.wrap; | ||
|
||
var OriginalHTMLOptionElement = window.HTMLOptionElement; | ||
|
||
function trimText(s) { | ||
return s.replace(/\s+/g, ' ').trim(); | ||
} | ||
|
||
function HTMLOptionElement(node) { | ||
HTMLElement.call(this, node); | ||
} | ||
HTMLOptionElement.prototype = Object.create(HTMLElement.prototype); | ||
mixin(HTMLOptionElement.prototype, { | ||
get text() { | ||
return trimText(this.textContent); | ||
}, | ||
set text(value) { | ||
this.textContent = trimText(String(value)); | ||
}, | ||
get form() { | ||
return wrap(unwrap(this).form); | ||
} | ||
}); | ||
|
||
registerWrapper(OriginalHTMLOptionElement, HTMLOptionElement, | ||
document.createElement('option')); | ||
|
||
function Option(text, value, defaultSelected, selected) { | ||
if (!(this instanceof Option)) { | ||
throw new TypeError( | ||
'DOM object constructor cannot be called as a function.'); | ||
} | ||
|
||
var node = unwrap(document.createElement('option')); | ||
HTMLElement.call(this, node); | ||
rewrap(node, this); | ||
|
||
if (text !== undefined) | ||
node.text = text; | ||
if (value !== undefined) | ||
node.setAttribute('value', value); | ||
if (defaultSelected === true) | ||
node.setAttribute('selected', ''); | ||
node.selected = selected === true; | ||
} | ||
|
||
Option.prototype = HTMLOptionElement.prototype; | ||
|
||
scope.wrappers.HTMLOptionElement = HTMLOptionElement; | ||
scope.wrappers.Option = Option; | ||
})(this.ShadowDOMPolyfill); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2013 The Polymer Authors. All rights reserved. | ||
* Use of this source code is goverened by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('HTMLAudioElement', function() { | ||
|
||
test('instanceof', function() { | ||
var audio = document.createElement('audio'); | ||
assert.instanceOf(audio, HTMLAudioElement); | ||
assert.instanceOf(audio, Audio); | ||
assert.instanceOf(audio, HTMLMediaElement); | ||
assert.instanceOf(audio, HTMLElement); | ||
}); | ||
|
||
test('Audio', function() { | ||
var audio = new Audio(); | ||
assert.instanceOf(audio, HTMLAudioElement); | ||
assert.instanceOf(audio, Audio); | ||
assert.instanceOf(audio, HTMLMediaElement); | ||
assert.instanceOf(audio, HTMLElement); | ||
}); | ||
|
||
test('Audio arguments', function() { | ||
var audio = new Audio(); | ||
assert.isFalse(audio.hasAttribute('src')); | ||
assert.equal(audio.getAttribute('preload', 'auto')); | ||
|
||
var src = 'foo.wav'; | ||
var audio = new Audio(src); | ||
assert.equal(audio.getAttribute('src', 'foo.wav')); | ||
}); | ||
|
||
test('Audio called as function', function() { | ||
assert.throws(Audio, TypeError); | ||
}); | ||
|
||
test('Audio basics', function() { | ||
var audio = new Audio(); | ||
assert.equal('audio', audio.localName); | ||
|
||
var div = document.createElement('div'); | ||
div.appendChild(audio); | ||
|
||
assert.equal(div.firstChild, audio); | ||
assert.equal('<div><audio></div>', div.outerHTML); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters