Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Commit e86d845

Browse files
committed
A few bug fixes
Ugh, already up to 0.2.3 :'( Fix config parsing Fixes #26
1 parent f21125e commit e86d845

File tree

7 files changed

+35
-15
lines changed

7 files changed

+35
-15
lines changed

lib/optparser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var DEFAULT = 'vulcanized.html';
1212

1313
// validate options with boolean return
1414
function processOptions(options, callback) {
15-
excludes = {
15+
var excludes = {
1616
imports: [ABS_URL],
1717
scripts: [ABS_URL],
1818
styles: [ABS_URL]
@@ -37,7 +37,7 @@ function processOptions(options, callback) {
3737
return callback('Malformed config JSON!');
3838
}
3939
if (config.excludes) {
40-
var e = options.excludes;
40+
var e = config.excludes;
4141
try {
4242
if (e.imports) {
4343
e.imports.forEach(function(r) {
@@ -59,6 +59,7 @@ function processOptions(options, callback) {
5959
}
6060
}
6161
}
62+
options.excludes = excludes;
6263

6364
if (!options.output) {
6465
options.output = path.resolve(path.dirname(options.input), DEFAULT);

lib/pathresolver.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66

77
var path = require('path');
88
var constants = require('./constants.js');
9-
10-
// directly update the textnode child of <style>
11-
// equivalent to <style>.textContent
12-
function setTextContent(node, text) {
13-
node[0].children[0].data = text;
14-
}
9+
var setTextContent = require('./utils.js').setTextContent;
1510

1611
function resolvePaths($, input, output) {
1712
var assetPath = path.relative(output, input);

lib/utils.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2013 The Polymer Authors. All rights reserved.
3+
* Use of this source code is governed by a BSD-style
4+
* license that can be found in the LICENSE file.
5+
*/
6+
7+
module.exports = {
8+
// directly update the textnode child of <style>
9+
// equivalent to <style>.textContent
10+
setTextContent: function(node, text) {
11+
var child = node[0].children[0];
12+
if (child) {
13+
child.data = text;
14+
} else {
15+
node[0].children[0] = {
16+
data: text,
17+
type: 'text',
18+
next: null,
19+
prev: null,
20+
parent: node[0]
21+
};
22+
}
23+
}
24+
};

lib/vulcan.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var url = require('url');
1515
var constants = require('./constants.js');
1616
var optparser = require('./optparser.js');
1717
var pathresolver = require('./pathresolver');
18+
var utils = require('./utils');
1819

1920
var read = {};
2021
var options = {};
@@ -37,21 +38,19 @@ function exclude(regexes, href) {
3738
}
3839

3940
function excludeImport(href) {
40-
return exclude(excludes.imports, href);
41+
return exclude(options.excludes.imports, href);
4142
}
4243

4344
function excludeScript(href) {
44-
return exclude(excludes.scripts, href);
45+
return exclude(options.excludes.scripts, href);
4546
}
4647

4748
function excludeStyle(href) {
48-
return exclude(excludes.styles, href);
49+
return exclude(options.excludes.styles, href);
4950
}
5051

51-
// directly update the textnode child of <style>
52-
// equivalent to <style>.textContent
5352
function setTextContent(node, text) {
54-
node[0].children[0].data = text;
53+
utils.setTextContent(node, text);
5554
}
5655

5756
function readFile(file) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vulcanize",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Process Web Components into one output file",
55
"main": "lib/vulcan.js",
66
"bin": {

test/empty.css

Whitespace-only changes.

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<script src="bower_components/platform/platform.js"></script>
77
<link rel="import" href="absolutes.html">
88
<link rel="import" href="import-test.html" />
9+
<link rel="stylesheet" href="empty.css">
910
</head>
1011
<body>
1112
<x-import>Hello Import!</x-import>

0 commit comments

Comments
 (0)