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

2.2.0 Release #221

Merged
merged 24 commits into from
Sep 22, 2020
Merged

2.2.0 Release #221

merged 24 commits into from
Sep 22, 2020

Conversation

pipwerks
Copy link
Owner

  • New behavior: Dropping support for IE9 and IE10, which have practically 0 marketshare now.
  • New behavior: Now explicitly displaying fallback content for all mobile devices, even "Request Desktop" versionof pages in iOS. The reasoning is simple: As the time of this update, no mobile device (Android, iOS) natively supports embedded PDFs. This change will lead to a consistent experience across all mobile devices. PDFs can be rendered via PDF.js on mobile if embedding on mobile is a critical need. PDF.js is not included with PDFObject.
  • New option: Omit inline styles by setting option omitInlineStyles to true. This helps developers who use strict environments where inline styles are not allowed. Note you will be responsible for applying proper styling via your own CSS.
  • New option: Suppress console logging by setting option suppressConsole to true. PDFObject current places error messages in the console if the PDF can't be embedded for some reason. This optioon allows you to mute those alerts.
  • New option: Force PDFObject to embed the PDF in an iframe (instead of an <embed>) by setting forceIframe to true.
  • Refactored to use more modern code conventions, such as let in lieu of var, el.classList.add() in place of el.className = 'foo', and myvar === undefined in place of typeof myvar === "undefined". Implemented a let declaration before each variable instead of the Crockford practice of one var per function.
  • Refactored to make code safer for server-side node.js-based environments.
  • Refactored to eliminate string-based element creation via innerHTML. Replaced with standard DOM methods. This helps alleviate unforeseen issues with file names. Only exception is insertion of fallback content, which is passed as a string via innerHTML.
  • Removed iframe scrollfix for iOS, as it is no longer needed as of iOS13. iOS 12 and lower have ~5-7% marketshare and shrinking fast.
  • Refactored codebase to make it more concise and legible.

Removed isIOS references in favor of isMobileDevice.

Removed scrollfix for iOS, as it is no longer needed as of iOS13. iOS 12 and lower have ~5-7% marketshare and shrinking fast.
Expanded detection where needed (Safari desktop vs iPad), simplified where possible, and added more object checks (e.g. navigator.mimeTypes) for safely working in nodejs environment
All modern browser support console, as does nodejs. Removed safety check for console and deleted custom log function
Switched to pure DOM methods in place of innerHTML.

(Left innerHTML for fallback string option)
Replaced custom addClass function with standard classList (supported in IE11 and all modern browsers)
Consolidated two similar functions into one.
Standardized on double quotes
Missed a spot
Switching from typeof checks to direct comparisons. undefined cannot be redefined in modern browsers and is safer to use than it used to be. It's also more concise.

Also replaced ternary statements with || where applicable to make code more concise.
Resolves #200 .

Option `omitInlineStyles = true` will instruct PDFObject to embed the PDF without using inline styles. **The embed will appear broken if the developer does not provide appropriate styles via their own CSS.**
set `suppressConsole = true` to prevent PDFObject from writing error messages to the console
Mostly just code cleanup
AKA dragging PDFObject to ECMAScript 2015 kicking and screaming by using `let` and multiple declarations per function instead of the Corckford one var per func standard.
Set `forceIframe = true` to force PDFObject to use iframes for the embed. Has no effect on `forcePDFJS` option.
Old embed method used innerHTML, which would clear out any prior content. Now that we're using DOM methods, we need to add an extra check to ensure the node is empty instead of simply appending new content to existing content
Old check used typeof which was verbose but safe. New method uses direct comparison to `undefined` but this requires var being checked to be in global scope (in window) otherwise will throw an error
Corrected ID assignment (DOM instead of string), and added a check for existence of ID before trying to assign to DOM element (avoid assigning empty string).
1. Don't set styles directly
2. isIE is no longer a function
@pipwerks pipwerks merged commit 5dede67 into master Sep 22, 2020
@pipwerks pipwerks deleted the 2.2-development branch May 6, 2023 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant