Merge pull request #5108 from timvandermeij/strict-equalities

Use strict equalities in web/*
This commit is contained in:
Tim van der Meij 2014-08-01 19:26:14 +02:00
commit 49142e9d5a
5 changed files with 23 additions and 23 deletions

View File

@ -237,7 +237,7 @@ if (typeof PDFJS === 'undefined') {
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
window.atob = function (input) { window.atob = function (input) {
input = input.replace(/=+$/, ''); input = input.replace(/=+$/, '');
if (input.length % 4 == 1) { if (input.length % 4 === 1) {
throw new Error('bad atob input'); throw new Error('bad atob input');
} }
for ( for (
@ -293,7 +293,7 @@ if (typeof PDFJS === 'undefined') {
var dataset = {}; var dataset = {};
for (var j = 0, jj = this.attributes.length; j < jj; j++) { for (var j = 0, jj = this.attributes.length; j < jj; j++) {
var attribute = this.attributes[j]; var attribute = this.attributes[j];
if (attribute.name.substring(0, 5) != 'data-') { if (attribute.name.substring(0, 5) !== 'data-') {
continue; continue;
} }
var key = attribute.name.substring(5).replace(/\-([a-z])/g, var key = attribute.name.substring(5).replace(/\-([a-z])/g,
@ -416,7 +416,7 @@ if (typeof PDFJS === 'undefined') {
function isDisabled(node) { function isDisabled(node) {
return node.disabled || (node.parentNode && isDisabled(node.parentNode)); return node.disabled || (node.parentNode && isDisabled(node.parentNode));
} }
if (navigator.userAgent.indexOf('Opera') != -1) { if (navigator.userAgent.indexOf('Opera') !== -1) {
// use browser detection since we cannot feature-check this bug // use browser detection since we cannot feature-check this bug
document.addEventListener('click', ignoreIfTargetDisabled, true); document.addEventListener('click', ignoreIfTargetDisabled, true);
} }

View File

@ -53,7 +53,7 @@ var FontInspector = (function FontInspectorClosure() {
var selects = document.getElementsByTagName('input'); var selects = document.getElementsByTagName('input');
for (var i = 0; i < selects.length; ++i) { for (var i = 0; i < selects.length; ++i) {
var select = selects[i]; var select = selects[i];
if (select.dataset.fontName != fontName) { if (select.dataset.fontName !== fontName) {
continue; continue;
} }
select.checked = !select.checked; select.checked = !select.checked;
@ -216,7 +216,7 @@ var StepperManager = (function StepperManagerClosure() {
} }
for (i = 0; i < steppers.length; ++i) { for (i = 0; i < steppers.length; ++i) {
var stepper = steppers[i]; var stepper = steppers[i];
if (stepper.pageIndex == pageIndex) { if (stepper.pageIndex === pageIndex) {
stepper.panel.removeAttribute('hidden'); stepper.panel.removeAttribute('hidden');
} else { } else {
stepper.panel.setAttribute('hidden', true); stepper.panel.setAttribute('hidden', true);
@ -225,7 +225,7 @@ var StepperManager = (function StepperManagerClosure() {
var options = stepperChooser.options; var options = stepperChooser.options;
for (i = 0; i < options.length; ++i) { for (i = 0; i < options.length; ++i) {
var option = options[i]; var option = options[i];
option.selected = option.value == pageIndex; option.selected = (option.value | 0) === pageIndex;
} }
}, },
saveBreakPoints: function saveBreakPoints(pageIndex, bps) { saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
@ -332,7 +332,7 @@ var Stepper = (function StepperClosure() {
line.className = 'line'; line.className = 'line';
line.dataset.idx = i; line.dataset.idx = i;
chunk.appendChild(line); chunk.appendChild(line);
var checked = this.breakPoints.indexOf(i) != -1; var checked = this.breakPoints.indexOf(i) !== -1;
var args = operatorList.argsArray[i] || []; var args = operatorList.argsArray[i] || [];
var breakCell = c('td'); var breakCell = c('td');
@ -419,7 +419,7 @@ var Stepper = (function StepperClosure() {
var allRows = this.panel.getElementsByClassName('line'); var allRows = this.panel.getElementsByClassName('line');
for (var x = 0, xx = allRows.length; x < xx; ++x) { for (var x = 0, xx = allRows.length; x < xx; ++x) {
var row = allRows[x]; var row = allRows[x];
if (row.dataset.idx == idx) { if (parseInt(row.dataset.idx, 10) === idx) {
row.style.backgroundColor = 'rgb(251,250,207)'; row.style.backgroundColor = 'rgb(251,250,207)';
row.scrollIntoView(); row.scrollIntoView();
} else { } else {
@ -597,7 +597,7 @@ var PDFBug = (function PDFBugClosure() {
activePanel = index; activePanel = index;
var tools = this.tools; var tools = this.tools;
for (var j = 0; j < tools.length; ++j) { for (var j = 0; j < tools.length; ++j) {
if (j == index) { if (j === index) {
buttons[j].setAttribute('class', 'active'); buttons[j].setAttribute('class', 'active');
tools[j].active = true; tools[j].active = true;
tools[j].panel.removeAttribute('hidden'); tools[j].panel.removeAttribute('hidden');

View File

@ -171,10 +171,10 @@ var DocumentProperties = {
// As per spec, utRel = 'Z' means equal to universal time. // As per spec, utRel = 'Z' means equal to universal time.
// The other cases ('-' and '+') have to be handled here. // The other cases ('-' and '+') have to be handled here.
if (utRel == '-') { if (utRel === '-') {
hours += offsetHours; hours += offsetHours;
minutes += offsetMinutes; minutes += offsetMinutes;
} else if (utRel == '+') { } else if (utRel === '+') {
hours -= offsetHours; hours -= offsetHours;
minutes += offsetMinutes; minutes += offsetMinutes;
} }

View File

@ -30,7 +30,7 @@ var CustomStyle = (function CustomStyleClosure() {
CustomStyle.getProp = function get(propName, element) { CustomStyle.getProp = function get(propName, element) {
// check cache only when no element is given // check cache only when no element is given
if (arguments.length == 1 && typeof _cache[propName] == 'string') { if (arguments.length === 1 && typeof _cache[propName] === 'string') {
return _cache[propName]; return _cache[propName];
} }
@ -38,7 +38,7 @@ var CustomStyle = (function CustomStyleClosure() {
var style = element.style, prefixed, uPropName; var style = element.style, prefixed, uPropName;
// test standard property first // test standard property first
if (typeof style[propName] == 'string') { if (typeof style[propName] === 'string') {
return (_cache[propName] = propName); return (_cache[propName] = propName);
} }
@ -48,7 +48,7 @@ var CustomStyle = (function CustomStyleClosure() {
// test vendor specific properties // test vendor specific properties
for (var i = 0, l = prefixes.length; i < l; i++) { for (var i = 0, l = prefixes.length; i < l; i++) {
prefixed = prefixes[i] + uPropName; prefixed = prefixes[i] + uPropName;
if (typeof style[prefixed] == 'string') { if (typeof style[prefixed] === 'string') {
return (_cache[propName] = prefixed); return (_cache[propName] = prefixed);
} }
} }
@ -59,7 +59,7 @@ var CustomStyle = (function CustomStyleClosure() {
CustomStyle.setProp = function set(propName, element, str) { CustomStyle.setProp = function set(propName, element, str) {
var prop = this.getProp(propName); var prop = this.getProp(propName);
if (prop != 'undefined') { if (prop !== 'undefined') {
element.style[prop] = str; element.style[prop] = str;
} }
}; };
@ -93,7 +93,7 @@ function getOutputScale(ctx) {
return { return {
sx: pixelRatio, sx: pixelRatio,
sy: pixelRatio, sy: pixelRatio,
scaled: pixelRatio != 1 scaled: pixelRatio !== 1
}; };
} }
@ -161,7 +161,7 @@ function getPDFFileNameFromURL(url) {
reFilename.exec(splitURI[3]); reFilename.exec(splitURI[3]);
if (suggestedFilename) { if (suggestedFilename) {
suggestedFilename = suggestedFilename[0]; suggestedFilename = suggestedFilename[0];
if (suggestedFilename.indexOf('%') != -1) { if (suggestedFilename.indexOf('%') !== -1) {
// URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf // URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
try { try {
suggestedFilename = suggestedFilename =

View File

@ -805,7 +805,7 @@ var PDFView = {
var pdfOpenParams = PDFView.getAnchorUrl('#page=' + pageNumber); var pdfOpenParams = PDFView.getAnchorUrl('#page=' + pageNumber);
var destKind = dest[1]; var destKind = dest[1];
if (typeof destKind === 'object' && 'name' in destKind && if (typeof destKind === 'object' && 'name' in destKind &&
destKind.name == 'XYZ') { destKind.name === 'XYZ') {
var scale = (dest[4] || this.currentScaleValue); var scale = (dest[4] || this.currentScaleValue);
var scaleNumber = parseFloat(scale); var scaleNumber = parseFloat(scale);
if (scaleNumber) { if (scaleNumber) {
@ -1668,9 +1668,9 @@ var PDFView = {
// In case we are already on the first or the last page there is no need // In case we are already on the first or the last page there is no need
// to do anything. // to do anything.
if ((currentPage == 1 && pageFlipDirection == PageFlipDirection.UP) || if ((currentPage === 1 && pageFlipDirection === PageFlipDirection.UP) ||
(currentPage == this.pages.length && (currentPage === this.pages.length &&
pageFlipDirection == PageFlipDirection.DOWN)) { pageFlipDirection === PageFlipDirection.DOWN)) {
return; return;
} }
@ -1862,7 +1862,7 @@ function webViewerInitialized() {
var mainContainer = document.getElementById('mainContainer'); var mainContainer = document.getElementById('mainContainer');
var outerContainer = document.getElementById('outerContainer'); var outerContainer = document.getElementById('outerContainer');
mainContainer.addEventListener('transitionend', function(e) { mainContainer.addEventListener('transitionend', function(e) {
if (e.target == mainContainer) { if (e.target === mainContainer) {
var event = document.createEvent('UIEvents'); var event = document.createEvent('UIEvents');
event.initUIEvent('resize', false, false, window, 0); event.initUIEvent('resize', false, false, window, 0);
window.dispatchEvent(event); window.dispatchEvent(event);
@ -2107,7 +2107,7 @@ function selectScaleOption(value) {
var predefinedValueFound = false; var predefinedValueFound = false;
for (var i = 0; i < options.length; i++) { for (var i = 0; i < options.length; i++) {
var option = options[i]; var option = options[i];
if (option.value != value) { if (option.value !== value) {
option.selected = false; option.selected = false;
continue; continue;
} }