Skip to content

Commit

Permalink
fix @license comments & shadycss imports. Remove custom style from ex…
Browse files Browse the repository at this point in the history
…terns
  • Loading branch information
dfreedm committed Mar 30, 2017
1 parent eea1ca2 commit 59350ad
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
10 changes: 0 additions & 10 deletions externs/webcomponents-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
* @externs
*/

/**
* @constructor
* @extends {HTMLElement}
*/
function CustomStyle(){}
/**
* @param {!HTMLStyleElement} style
*/
CustomStyle.prototype.processHook = function(style){};

let HTMLImports = {
/**
* @param {function()} callback
Expand Down
11 changes: 8 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
Expand Down
18 changes: 17 additions & 1 deletion util/minimalDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand All @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 59350ad

Please sign in to comment.