Skip to content

Commit

Permalink
Check webcomponents script for "webComponentsReady" flag
Browse files Browse the repository at this point in the history
The flag is set after WebComponentsReady event has been fired, so that
wct can know to run if it missed the WebComponentsReady event
  • Loading branch information
dfreedm committed Apr 22, 2017
1 parent ad59963 commit 1bbe898
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
13 changes: 7 additions & 6 deletions browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion browser.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions browser/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import * as config from './config.js';
*/
export function whenFrameworksReady(callback) {
debug('whenFrameworksReady');
var done = function() {
var done = function () {
debug('whenFrameworksReady done');
callback();
};

// If webcomponents script is in the document, wait for WebComponentsReady.
if (document.querySelector('script[src*="webcomponents"]')) {
var wcScript = document.querySelector('script[src*="webcomponents"]');
if (wcScript && !wcScript.webComponentsReady) {
debug('WebComponentsReady?');
window.addEventListener('WebComponentsReady', function wcReady() {
window.removeEventListener('WebComponentsReady', wcReady);
Expand Down Expand Up @@ -133,7 +134,7 @@ export function getParams(opt_query) {
if (query === '') return {};

var result = {};
query.split('&').forEach(function(part) {
query.split('&').forEach(function (part) {
var pair = part.split('=');
if (pair.length !== 2) {
console.warn('Invalid URL query part:', part);
Expand All @@ -158,7 +159,7 @@ export function getParams(opt_query) {
* @param {!Object<string, !Array<string>>} source
*/
export function mergeParams(target, source) {
Object.keys(source).forEach(function(key) {
Object.keys(source).forEach(function (key) {
if (!(key in target)) {
target[key] = [];
}
Expand All @@ -181,8 +182,8 @@ export function getParam(param) {
*/
export function paramsToQuery(params) {
var pairs = [];
Object.keys(params).forEach(function(key) {
params[key].forEach(function(value) {
Object.keys(params).forEach(function (key) {
params[key].forEach(function (value) {
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
});
});
Expand Down

0 comments on commit 1bbe898

Please sign in to comment.