From 59350ad408f5685bf1e618dd88bf0ce90a471f5f Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Thu, 30 Mar 2017 11:08:58 -0700 Subject: [PATCH] fix @license comments & shadycss imports. Remove custom style from externs --- externs/webcomponents-externs.js | 10 ---------- gulpfile.js | 11 ++++++++--- util/minimalDocument.js | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/externs/webcomponents-externs.js b/externs/webcomponents-externs.js index 55e8aaef38..121b5d1925 100644 --- a/externs/webcomponents-externs.js +++ b/externs/webcomponents-externs.js @@ -3,16 +3,6 @@ * @externs */ -/** - * @constructor - * @extends {HTMLElement} - */ -function CustomStyle(){} -/** - * @param {!HTMLStyleElement} style - */ -CustomStyle.prototype.processHook = function(style){}; - let HTMLImports = { /** * @param {function()} callback diff --git a/gulpfile.js b/gulpfile.js index e2c09b72cb..2225b11dab 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -102,10 +102,15 @@ gulp.task('closure', ['clean'], () => { joinRx = /polymer-element\.html/; } - element(); + // element(); + full(); const project = new PolymerProject({ - entrypoint: `./${entry}` + shell: `./${entry}`, + fragments: [ + 'bower_components/shadycss/apply-shim.html', + 'bower_components/shadycss/custom-style-interface.html' + ] }); const closureStream = closure({ @@ -121,7 +126,7 @@ gulp.task('closure', ['clean'], () => { 'externs/closure-upstream-externs.js', 'externs/webcomponents-externs.js', 'externs/polymer-externs.js', - 'externs/closure-types.js' + 'externs/closure-types.js', ], extra_annotation_name: [ 'polymerMixin', diff --git a/util/minimalDocument.js b/util/minimalDocument.js index fbc459daed..17d819497d 100644 --- a/util/minimalDocument.js +++ b/util/minimalDocument.js @@ -40,6 +40,20 @@ function replaceWithChildren(node) { parent.childNodes = parent.childNodes.slice(0, idx).concat(children, parent.childNodes.slice(til)); } +function onlyOneLicense(doc) { + let comments = dom5.nodeWalkAll(doc, dom5.isCommentNode); + let hasLicense = false; + for (let i = 0; i < comments.length; i++) { + let c = comments[i]; + let text = dom5.getTextContent(c); + if (text.indexOf('@license') === -1 || hasLicense) { + dom5.remove(c); + } else { + hasLicense = true; + } + } +} + class MinimalDocTransform extends Transform { constructor() { super({objectMode: true}); @@ -48,7 +62,7 @@ class MinimalDocTransform extends Transform { let doc = dom5.parse(String(file.contents)); let head = dom5.query(doc, p.hasTagName('head')); let body = dom5.query(doc, p.hasTagName('body')); - let vulc = dom5.query(body, p.AND(p.hasTagName('div'), p.hasAttr('by-vulcanize'), p.hasAttr('hidden'))); + let vulc = dom5.query(body, p.AND(p.hasTagName('div'), p.hasAttr('by-polymer-bundler'), p.hasAttr('hidden'))); let charset = dom5.query(doc, p.AND(p.hasTagName('meta'), p.hasAttrValue('charset', 'UTF-8'))); if (charset) { @@ -72,6 +86,8 @@ class MinimalDocTransform extends Transform { let html = dom5.query(doc, p.hasTagName('html')); replaceWithChildren(html); + onlyOneLicense(doc); + file.contents = new Buffer(dom5.serialize(doc)); cb(null, file);