diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/assetUrl.ts | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-89e95b3f143682ed9a006991bacf45c9dcba4818.tar.gz xmake-docs-89e95b3f143682ed9a006991bacf45c9dcba4818.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/assetUrl.ts')
| -rw-r--r-- | node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/assetUrl.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/assetUrl.ts b/node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/assetUrl.ts deleted file mode 100644 index b74b0596..00000000 --- a/node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/assetUrl.ts +++ /dev/null @@ -1,51 +0,0 @@ -// vue compiler module for transforming `<tag>:<attribute>` to `require` - -import { urlToRequire, ASTNode, Attr } from './utils' - -export interface AssetURLOptions { - [name: string]: string | string[] -} - -const defaultOptions: AssetURLOptions = { - video: ['src', 'poster'], - source: 'src', - img: 'src', - image: ['xlink:href', 'href'] -} - -export default (userOptions?: AssetURLOptions) => { - const options = userOptions - ? Object.assign({}, defaultOptions, userOptions) - : defaultOptions - - return { - postTransformNode: (node: ASTNode) => { - transform(node, options) - } - } -} - -function transform(node: ASTNode, options: AssetURLOptions) { - for (const tag in options) { - if ((tag === '*' || node.tag === tag) && node.attrs) { - const attributes = options[tag] - if (typeof attributes === 'string') { - node.attrs.some(attr => rewrite(attr, attributes)) - } else if (Array.isArray(attributes)) { - attributes.forEach(item => node.attrs.some(attr => rewrite(attr, item))) - } - } - } -} - -function rewrite(attr: Attr, name: string) { - if (attr.name === name) { - const value = attr.value - // only transform static URLs - if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') { - attr.value = urlToRequire(value.slice(1, -1)) - return true - } - } - return false -} |
