Skip to content

Commit

Permalink
fix: offset equal 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Apr 17, 2024
1 parent c6273f7 commit 374b590
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export class MagicStringAST implements MagicString {
this.offset = options?.offset ?? 0
return new Proxy(this.s, {
get: (target, p, receiver) => {
const current = Reflect.get(this, p, receiver)
if (current) return current
if (Reflect.has(this, p)) return Reflect.get(this, p, receiver)

let parent = Reflect.get(target, p, receiver)
if (typeof parent === 'function') parent = parent.bind(target)
Expand Down
1 change: 1 addition & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test('basic', () => {
s.append('hello')
expect(s.toString()).toBe('foohello')
expect(s instanceof MagicString).toBe(true)
expect(s.offset).toBe(0)
})

test('offset', () => {
Expand Down

0 comments on commit 374b590

Please sign in to comment.