mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix for viewport props w/ only key, no value
This commit is contained in:
@@ -25,8 +25,10 @@ function viewportLoadTag() {
|
||||
var props = viewportTag.content.toLowerCase().replace(/\s+/g, '').split(',');
|
||||
var keyValue;
|
||||
for(x=0; x<props.length; x++) {
|
||||
keyValue = props[x].split('=');
|
||||
if(keyValue.length == 2) viewportProperties[ keyValue[0] ] = keyValue[1];
|
||||
if(props[x] != '') {
|
||||
keyValue = props[x].split('=');
|
||||
viewportProperties[ keyValue[0] ] = (keyValue.length > 1 ? keyValue[1] : '_');
|
||||
}
|
||||
}
|
||||
viewportUpdate();
|
||||
}
|
||||
@@ -112,12 +114,12 @@ function viewportUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
function viewportTagUpdate(updates) {
|
||||
ionic.Utils.extend(viewportProperties, updates);
|
||||
|
||||
function viewportTagUpdate() {
|
||||
var key, props = [];
|
||||
for(key in viewportProperties) {
|
||||
if( viewportProperties[key] ) props.push(key + '=' + viewportProperties[key]);
|
||||
if( viewportProperties[key] ) {
|
||||
props.push(key + (viewportProperties[key] == '_' ? '' : '=' + viewportProperties[key]) );
|
||||
}
|
||||
}
|
||||
|
||||
viewportTag.content = props.join(', ');
|
||||
|
||||
@@ -479,6 +479,18 @@ describe('Ionic Viewport', function() {
|
||||
|
||||
|
||||
|
||||
it('Should set viewport properties that have a key but without a value', function(){
|
||||
vportTag.content = ' keyonly, , ,, WIDTH=DeViCe-wIDTH , minimal-ui ';
|
||||
viewportLoadTag();
|
||||
|
||||
expect( viewportProperties['keyonly'] ).toEqual('_');
|
||||
expect( viewportProperties['width'] ).toEqual('device-width');
|
||||
expect( viewportProperties['minimal-ui'] ).toEqual('_');
|
||||
|
||||
viewportTagUpdate();
|
||||
expect( vportTag.content ).toEqual('keyonly, width=device-width, minimal-ui');
|
||||
});
|
||||
|
||||
it('Should get portrait (0) orientation', function(){
|
||||
window.innerWidth = 768;
|
||||
window.innerHeight = 1024;
|
||||
|
||||
Reference in New Issue
Block a user