@vue/component-compiler-utils
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -0,1 +1,12 @@ | ||
<a name="2.3.0"></a> | ||
# [2.3.0](https://github.com/vuejs/component-compiler-utils/compare/v2.2.0...v2.3.0) (2018-10-22) | ||
### Bug Fixes | ||
* support standalone pseudo element selectors ([#33](https://github.com/vuejs/component-compiler-utils/issues/33)) ([d6cfbbf](https://github.com/vuejs/component-compiler-utils/commit/d6cfbbf)) | ||
* Typings for SFCDescriptor and SFCCustomBlock ([#29](https://github.com/vuejs/component-compiler-utils/issues/29)) ([bb09115](https://github.com/vuejs/component-compiler-utils/commit/bb09115)) | ||
<a name="2.2.0"></a> | ||
@@ -2,0 +13,0 @@ # [2.2.0](https://github.com/vuejs/component-compiler-utils/compare/v2.1.2...v2.2.0) (2018-08-16) |
@@ -14,7 +14,7 @@ import { RawSourceMap, VueTemplateCompiler, VueTemplateCompilerParseOptions } from './types'; | ||
attrs: { | ||
[key: string]: string; | ||
[key: string]: string | true; | ||
}; | ||
start: number; | ||
end: number; | ||
map: RawSourceMap; | ||
map?: RawSourceMap; | ||
} | ||
@@ -28,4 +28,4 @@ export interface SFCBlock extends SFCCustomBlock { | ||
export interface SFCDescriptor { | ||
template?: SFCBlock; | ||
script?: SFCBlock; | ||
template: SFCBlock | null; | ||
script: SFCBlock | null; | ||
styles: SFCBlock[]; | ||
@@ -32,0 +32,0 @@ customBlocks: SFCCustomBlock[]; |
@@ -26,3 +26,2 @@ "use strict"; | ||
let node = null; | ||
let hasDeep = false; | ||
selector.each((n) => { | ||
@@ -33,3 +32,2 @@ // ">>>" combinator | ||
n.spaces.before = n.spaces.after = ''; | ||
hasDeep = true; | ||
return false; | ||
@@ -44,3 +42,2 @@ } | ||
n.remove(); | ||
hasDeep = true; | ||
return false; | ||
@@ -54,11 +51,12 @@ } | ||
node.spaces.after = ''; | ||
selector.insertAfter(node, selectorParser.attribute({ | ||
attribute: id | ||
})); | ||
} | ||
else if (hasDeep) { | ||
selector.prepend(selectorParser.attribute({ | ||
attribute: id | ||
})); | ||
else { | ||
// For deep selectors & standalone pseudo selectors, | ||
// the attribute selectors are prepended rather than appended. | ||
// So all leading spaces must be eliminated to avoid problems. | ||
selector.first.spaces.before = ''; | ||
} | ||
selector.insertAfter(node, selectorParser.attribute({ | ||
attribute: id | ||
})); | ||
}); | ||
@@ -65,0 +63,0 @@ }).processSync(node.selector); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url_1 = require("url"); | ||
function urlToRequire(url) { | ||
const returnValue = `"${url}"`; | ||
// same logic as in transform-require.js | ||
@@ -11,8 +13,33 @@ const firstChar = url.charAt(0); | ||
} | ||
return `require("${url}")`; | ||
const uriParts = parseUriParts(url); | ||
if (!uriParts.hash) { | ||
return `require("${url}")`; | ||
} | ||
else { | ||
// support uri fragment case by excluding it from | ||
// the require and instead appending it as string; | ||
// assuming that the path part is sufficient according to | ||
// the above caseing(t.i. no protocol-auth-host parts expected) | ||
return `require("${uriParts.path}") + "${uriParts.hash}"`; | ||
} | ||
} | ||
else { | ||
return `"${url}"`; | ||
return returnValue; | ||
} | ||
exports.urlToRequire = urlToRequire; | ||
/** | ||
* vuejs/component-compiler-utils#22 Support uri fragment in transformed require | ||
* @param urlString an url as a string | ||
*/ | ||
function parseUriParts(urlString) { | ||
// initialize return value | ||
const returnValue = url_1.parse(''); | ||
if (urlString) { | ||
// A TypeError is thrown if urlString is not a string | ||
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost | ||
if ('string' === typeof urlString) { | ||
// check is an uri | ||
return url_1.parse(urlString); // take apart the uri | ||
} | ||
} | ||
return returnValue; | ||
} | ||
exports.urlToRequire = urlToRequire; |
@@ -26,6 +26,6 @@ import { | ||
content: string | ||
attrs: { [key: string]: string } | ||
attrs: { [key: string]: string | true } | ||
start: number | ||
end: number | ||
map: RawSourceMap | ||
map?: RawSourceMap | ||
} | ||
@@ -41,4 +41,4 @@ | ||
export interface SFCDescriptor { | ||
template?: SFCBlock | ||
script?: SFCBlock | ||
template: SFCBlock | null | ||
script: SFCBlock | null | ||
styles: SFCBlock[] | ||
@@ -45,0 +45,0 @@ customBlocks: SFCCustomBlock[] |
@@ -26,3 +26,3 @@ import { Root } from 'postcss' | ||
let node: any = null | ||
let hasDeep: boolean = false | ||
selector.each((n: any) => { | ||
@@ -33,3 +33,2 @@ // ">>>" combinator | ||
n.spaces.before = n.spaces.after = '' | ||
hasDeep = true | ||
return false | ||
@@ -44,3 +43,2 @@ } | ||
n.remove() | ||
hasDeep = true | ||
return false | ||
@@ -52,17 +50,18 @@ } | ||
}) | ||
if (node) { | ||
node.spaces.after = '' | ||
selector.insertAfter( | ||
node, | ||
selectorParser.attribute({ | ||
attribute: id | ||
}) | ||
) | ||
} else if (hasDeep) { | ||
selector.prepend( | ||
selectorParser.attribute({ | ||
attribute: id | ||
}) | ||
) | ||
} else { | ||
// For deep selectors & standalone pseudo selectors, | ||
// the attribute selectors are prepended rather than appended. | ||
// So all leading spaces must be eliminated to avoid problems. | ||
selector.first.spaces.before = '' | ||
} | ||
selector.insertAfter( | ||
node, | ||
selectorParser.attribute({ | ||
attribute: id | ||
}) | ||
) | ||
}) | ||
@@ -69,0 +68,0 @@ }).processSync(node.selector) |
@@ -11,3 +11,6 @@ export interface Attr { | ||
import { UrlWithStringQuery, parse as uriParse } from 'url' | ||
export function urlToRequire(url: string): string { | ||
const returnValue = `"${url}"` | ||
// same logic as in transform-require.js | ||
@@ -20,6 +23,34 @@ const firstChar = url.charAt(0) | ||
} | ||
return `require("${url}")` | ||
} else { | ||
return `"${url}"` | ||
const uriParts = parseUriParts(url) | ||
if (!uriParts.hash) { | ||
return `require("${url}")` | ||
} else { | ||
// support uri fragment case by excluding it from | ||
// the require and instead appending it as string; | ||
// assuming that the path part is sufficient according to | ||
// the above caseing(t.i. no protocol-auth-host parts expected) | ||
return `require("${uriParts.path}") + "${uriParts.hash}"` | ||
} | ||
} | ||
return returnValue | ||
} | ||
/** | ||
* vuejs/component-compiler-utils#22 Support uri fragment in transformed require | ||
* @param urlString an url as a string | ||
*/ | ||
function parseUriParts(urlString: string): UrlWithStringQuery { | ||
// initialize return value | ||
const returnValue: UrlWithStringQuery = uriParse('') | ||
if (urlString) { | ||
// A TypeError is thrown if urlString is not a string | ||
// @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost | ||
if ('string' === typeof urlString) { | ||
// check is an uri | ||
return uriParse(urlString) // take apart the uri | ||
} | ||
} | ||
return returnValue | ||
} |
{ | ||
"name": "@vue/component-compiler-utils", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Lower level utilities for compiling Vue single file components", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"lint": "prettier --write \"{lib,test}/**/*.ts\"", | ||
"test": "prettier --list-different \"{lib,test}/**/*.ts\" && jest", | ||
"test": "prettier --list-different \"{lib,test}/**/*.ts\" && jest --coverage", | ||
"build": "rm -rf dist && tsc", | ||
@@ -51,3 +51,4 @@ "prepublishOnly": "yarn build && conventional-changelog -p angular -r 2 -i CHANGELOG.md -s" | ||
"typescript": "^2.7.2", | ||
"vue-template-compiler": "^2.5.16", | ||
"vue": "^2.5.17", | ||
"vue-template-compiler": "^2.5.17", | ||
"yorkie": "^1.0.3" | ||
@@ -54,0 +55,0 @@ }, |
@@ -34,4 +34,4 @@ # @vue/component-compiler-utils [![Build Status](https://circleci.com/gh/vuejs/component-compiler-utils/tree/master.svg?style=shield)](https://circleci.com/gh/vuejs/component-compiler-utils/) | ||
interface SFCDescriptor { | ||
template?: SFCBlock | ||
script?: SFCBlock | ||
template: SFCBlock | null | ||
script: SFCBlock | null | ||
styles: SFCBlock[] | ||
@@ -44,6 +44,6 @@ customBlocks: SFCCustomBlock[] | ||
content: string | ||
attrs: { [key: string]: string } | ||
attrs: { [key: string]: string | true } | ||
start: number | ||
end: number | ||
map: RawSourceMap | ||
map?: RawSourceMap | ||
} | ||
@@ -50,0 +50,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
315134
61
2232
14