Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore video tag attributes on tech change #1369

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
API consistency, getAttributeValues renamed to getElementAttributes
  • Loading branch information
dcharbonnier committed Jul 25, 2014
commit b54f5e24811d414c40f87877b669cfbf53008d75
2 changes: 1 addition & 1 deletion src/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ vjs.TOUCH_ENABLED = !!(('ontouchstart' in window) || window.DocumentTouch && doc
* @return {Object}
* @private
*/
vjs.getAttributeValues = function(tag){
vjs.getElementAttributes = function(tag){
var obj, knownBooleans, attrs, attrName, attrVal;

obj = {};
Expand Down
8 changes: 4 additions & 4 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ vjs.Player = vjs.Component.extend({
init: function(tag, options, ready){
this.tag = tag; // Store the original tag used to set options

this.tagAttributes = (tag) ? vjs.getAttributeValues(tag) : {}; // Store the tag attributes used to restore html5 tech
this.tagAttributes = (tag) ? vjs.getElementAttributes(tag) : {}; // Store the tag attributes used to restore html5 tech

// Make sure tag ID exists
tag.id = tag.id || 'vjs_video_' + vjs.guid++;
Expand Down Expand Up @@ -137,7 +137,7 @@ vjs.Player.prototype.getTagSettings = function(tag){
'tracks': []
};

vjs.obj.merge(options, vjs.getAttributeValues(tag));
vjs.obj.merge(options, vjs.getElementAttributes(tag));

// Get tag children settings
if (tag.hasChildNodes()) {
Expand All @@ -150,9 +150,9 @@ vjs.Player.prototype.getTagSettings = function(tag){
// Change case needed: http://ejohn.org/blog/nodename-case-sensitivity/
childName = child.nodeName.toLowerCase();
if (childName === 'source') {
options['sources'].push(vjs.getAttributeValues(child));
options['sources'].push(vjs.getElementAttributes(child));
} else if (childName === 'track') {
options['tracks'].push(vjs.getAttributeValues(child));
options['tracks'].push(vjs.getElementAttributes(child));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/unit/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ test('should read tag attributes from elements, including HTML5 in all browsers'

document.getElementById('qunit-fixture').innerHTML += tags;

var vid1Vals = vjs.getAttributeValues(document.getElementById('vid1'));
var vid2Vals = vjs.getAttributeValues(document.getElementById('vid2'));
var sourceVals = vjs.getAttributeValues(document.getElementById('source'));
var trackVals = vjs.getAttributeValues(document.getElementById('track'));
var vid1Vals = vjs.getElementAttributes(document.getElementById('vid1'));
var vid2Vals = vjs.getElementAttributes(document.getElementById('vid2'));
var sourceVals = vjs.getElementAttributes(document.getElementById('source'));
var trackVals = vjs.getElementAttributes(document.getElementById('track'));

// was using deepEqual, but ie8 would send all properties as attributes

Expand Down Expand Up @@ -161,7 +161,7 @@ test('should set tag attributes from object', function(){
var el = document.getElementById('vid1');
vjs.setElementAttributes(el, {controls: false,'data-test': 'asdf'});

var vid1Vals = vjs.getAttributeValues(document.getElementById('vid1'));
var vid1Vals = vjs.getElementAttributes(document.getElementById('vid1'));

equal(vid1Vals['controls'], undefined);
equal(vid1Vals['id'], 'vid1');
Expand Down
2 changes: 1 addition & 1 deletion test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test('should accept options from multiple sources and override in correct order'
});

test('should get tag, source, and track settings', function(){
// Partially tested in lib->getAttributeValues
// Partially tested in lib->getElementAttributes

var fixture = document.getElementById('qunit-fixture');

Expand Down