Skip to content

Commit

Permalink
Use slice for startsWith
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Mar 4, 2019
1 parent 12446c8 commit 9a8ca40
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/modify-template.ts
Expand Up @@ -69,5 +69,5 @@ const removePartForMarker =

const isPartMarker = (comment: Node|null): comment is Comment => {
return comment !== null && comment.nodeType === 8 /* Node.COMMENT_NODE */ &&
(comment as Comment).data.lastIndexOf(partMarker, 0) === 0;
(comment as Comment).data.slice(0, partMarker.length) === partMarker;
};
2 changes: 1 addition & 1 deletion src/lib/template-instance.ts
Expand Up @@ -95,7 +95,7 @@ export class TemplateInstance {
}

// Does this comment start with the part marker?
if (data.lastIndexOf(partMarker, 0) === 0) {
if (data.slice(0, partMarker.length) === partMarker) {
// The part marker packs the part index in the 16 low bits and
// attribute count (if it's an attribute binding) in the 16 high bits.
const packed = parseInt(data.slice(partMarker.length), 10);
Expand Down

0 comments on commit 9a8ca40

Please sign in to comment.