diff --git a/packages/autoupdate/autoupdate_client.js b/packages/autoupdate/autoupdate_client.js index d780df1c85..21d6fd2823 100644 --- a/packages/autoupdate/autoupdate_client.js +++ b/packages/autoupdate/autoupdate_client.js @@ -107,13 +107,13 @@ Autoupdate._retrySubscription = function () { } }; - var attachStylesheetLink = function (newLink) { - var removeOldLinks = _.after(newCss.length, function () { - _.each(oldLinks, function (oldLink) { - oldLink.parentNode.removeChild(oldLink); - }); + var removeOldLinks = _.after(newCss.length, function () { + _.each(oldLinks, function (oldLink) { + oldLink.parentNode.removeChild(oldLink); }); + }); + var attachStylesheetLink = function (newLink) { document.getElementsByTagName("head").item(0).appendChild(newLink); waitUntilCssLoads(newLink, function () { @@ -121,14 +121,19 @@ Autoupdate._retrySubscription = function () { }); }; - _.each(newCss, function (css) { - var newLink = document.createElement("link"); - newLink.setAttribute("rel", "stylesheet"); - newLink.setAttribute("type", "text/css"); - newLink.setAttribute("class", "__meteor-css__"); - newLink.setAttribute("href", css.url); - attachStylesheetLink(newLink); - }); + if (newCss.length !== 0) { + _.each(newCss, function (css) { + var newLink = document.createElement("link"); + newLink.setAttribute("rel", "stylesheet"); + newLink.setAttribute("type", "text/css"); + newLink.setAttribute("class", "__meteor-css__"); + newLink.setAttribute("href", css.url); + attachStylesheetLink(newLink); + }); + } else { + removeOldLinks(); + } + } else if (doc._id === 'version' && doc.version !== autoupdateVersion) { handle && handle.stop(); diff --git a/scripts/admin/jsdoc/docdata-jsdoc-template/publish.js b/scripts/admin/jsdoc/docdata-jsdoc-template/publish.js index 1a23ebecdf..358f98d74a 100644 --- a/scripts/admin/jsdoc/docdata-jsdoc-template/publish.js +++ b/scripts/admin/jsdoc/docdata-jsdoc-template/publish.js @@ -12,7 +12,7 @@ /** * Get a tag dictionary from the tags field on the object, for custom fields * like package - * @param {JSDoc object} data The thing you get in the TaffyDB from JSDoc + * @param {JSDocData} data The thing you get in the TaffyDB from JSDoc * @return {Object} Keys are the parameter names, values are the values. */ var getTagDict = function (data) { diff --git a/scripts/admin/jsdoc/jsdoc.sh b/scripts/admin/jsdoc/jsdoc.sh index 65a2e6713a..223479c083 100755 --- a/scripts/admin/jsdoc/jsdoc.sh +++ b/scripts/admin/jsdoc/jsdoc.sh @@ -5,10 +5,15 @@ cd $(dirname $0) cd ../../.. TOPDIR=$(pwd) +INFINITY=10000 + cd $TOPDIR -${TOPDIR}/dev_bundle/bin/node \ +# Call git grep to find all js files with the appropriate comment tags, +# and only then pass it to JSDoc which will parse the JS files. +# This is a whole lot faster than calling JSDoc recursively. +git grep -al "@summary" | xargs -L ${INFINITY} -t \ + ${TOPDIR}/dev_bundle/bin/node \ ${TOPDIR}/dev_bundle/lib/node_modules/.bin/jsdoc \ -t "${TOPDIR}/scripts/admin/jsdoc/docdata-jsdoc-template" \ - -c "${TOPDIR}/scripts/admin/jsdoc/jsdoc-conf.json" \ - -r "${TOPDIR}/packages" "${TOPDIR}/tools" + -c "${TOPDIR}/scripts/admin/jsdoc/jsdoc-conf.json" \ No newline at end of file diff --git a/tools/bundler.js b/tools/bundler.js index b42b5b8f2a..5eb2fe7466 100644 --- a/tools/bundler.js +++ b/tools/bundler.js @@ -837,6 +837,9 @@ _.extend(ClientTarget.prototype, { // Overwrite the CSS files list with the new concatenated file var stringifiedCss = CssTools.stringifyCss(self._cssAstCache, { sourcemap: true }); + if (! stringifiedCss.code) + return; + self.css = [new File({ data: new Buffer(stringifiedCss.code, 'utf8') })]; // Add the contents of the input files to the source map of the new file @@ -884,9 +887,10 @@ _.extend(ClientTarget.prototype, { minifiedCss = minifiers.CssTools.minifyCss(allCss); } - - self.css = [new File({ data: new Buffer(minifiedCss, 'utf8') })]; - self.css[0].setUrlToHash(".css", "?meteor_css_resource=true"); + if (!! minifiedCss) { + self.css = [new File({ data: new Buffer(minifiedCss, 'utf8') })]; + self.css[0].setUrlToHash(".css", "?meteor_css_resource=true"); + } }, // Output the finished target to disk diff --git a/tools/tests/apps/css-injection-test/css-injection-test.js b/tools/tests/apps/css-injection-test/css-injection-test.js index c78d3f3bdd..89eb2f3c5b 100644 --- a/tools/tests/apps/css-injection-test/css-injection-test.js +++ b/tools/tests/apps/css-injection-test/css-injection-test.js @@ -3,10 +3,20 @@ if (Meteor.isClient) { return $(document.body).css('background-color'); }; + var linkHref = function () { + var links = document.getElementsByTagName('link'); + if (links.length > 0) { + return links[0].href; + } else { + return null; + } + } + Meteor.startup(function () { Meteor.call("clientLoad"); var numCssChanges = 0; var oldBackgroundColor = backgroundColor(); + var oldLinkHref = linkHref(); Meteor.call("newStylesheet", numCssChanges, oldBackgroundColor); var waitingForCssReloadToComplete = false; Meteor.setInterval(function () { @@ -19,10 +29,10 @@ if (Meteor.isClient) { // give the client some time to load the new css var handle = Meteor.setInterval(function () { - var numberLinks = document.getElementsByTagName('link').length; - if (numberLinks === 1) { - // numberLinks will be 1 once the old css link is removed. + var newLinkHref = linkHref(); + if (newLinkHref !== oldLinkHref) { oldBackgroundColor = backgroundColor(); + oldLinkHref = newLinkHref; Meteor.call("newStylesheet", ++numCssChanges, oldBackgroundColor); waitingForCssReloadToComplete = false; Meteor.clearInterval(handle);