Skip to content

Commit 78c8ab9

Browse files
committed
inlined parse_tag_attributes
1 parent daaeb4c commit 78c8ab9

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/compiler/preprocess/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { RawSourceMap, DecodedSourceMap } from '@ampproject/remapping/dist/types
22
import { getLocator } from 'locate-character';
33
import { StringWithSourcemap, SourceLocation, sourcemap_add_offset, combine_sourcemaps } from '../utils/string_with_sourcemap';
44
import { decode_map } from './decode_sourcemap';
5-
import parse_tag_attributes from './parse_tag_attributes';
65
import { replace_in_code, Source } from './replace_in_code';
76
import { Preprocessor, PreprocessorGroup, Processed } from './types';
87

@@ -113,6 +112,16 @@ function processed_tag_to_sws(
113112
return tag_open_sws.concat(content_sws).concat(tag_close_sws);
114113
}
115114

115+
function parse_tag_attributes(str: string) {
116+
// note: won't work with attribute values containing spaces.
117+
return str.split(/\s+/).filter(Boolean).reduce((attrs, attr) => {
118+
const [key, value] = attr.split('=');
119+
const [,unquoted] = value && value.match(/^['"](.*)['"]$/) || [];
120+
121+
return {...attrs, [key]: unquoted ?? value ?? true};
122+
}, {});
123+
}
124+
116125
/**
117126
* Calculate the updates required to process all instances of the specified tag.
118127
*/

src/compiler/preprocess/parse_tag_attributes.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)