Skip to content

Commit 762ba62

Browse files
committed
Update vfile-location
1 parent 8df84b7 commit 762ba62

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Diff for: lib/index.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* @typedef {import('vfile').VFile} VFile
3-
* @typedef {import('vfile-location').Location} VFileLocation
43
* @typedef {import('property-information').Schema} Schema
54
* @typedef {import('unist').Position} Position
65
* @typedef {import('unist').Point} Point
@@ -45,7 +44,7 @@
4544

4645
import {h, s} from 'hastscript'
4746
import {html, svg, find} from 'property-information'
48-
import vfileLocation from 'vfile-location'
47+
import {location} from 'vfile-location'
4948
import {webNamespaces} from 'web-namespaces'
5049

5150
const own = {}.hasOwnProperty
@@ -118,7 +117,7 @@ function transform(ctx, ast) {
118117

119118
if ('sourceCodeLocation' in ast && ast.sourceCodeLocation && ctx.file) {
120119
// @ts-expect-error It’s fine.
121-
const position = location(ctx, result, ast.sourceCodeLocation)
120+
const position = createLocation(ctx, result, ast.sourceCodeLocation)
122121

123122
if (position) {
124123
ctx.location = true
@@ -170,10 +169,10 @@ function root(ctx, ast, children) {
170169

171170
if (ctx.file && ctx.location) {
172171
const doc = String(ctx.file)
173-
const location = vfileLocation(doc)
172+
const loc = location(doc)
174173
result.position = {
175-
start: location.toPoint(0),
176-
end: location.toPoint(doc.length)
174+
start: loc.toPoint(0),
175+
end: loc.toPoint(doc.length)
177176
}
178177
}
179178

@@ -262,7 +261,7 @@ function element(ctx, ast, children) {
262261
* @param {P5ElementLocation} location
263262
* @returns {Position|null}
264263
*/
265-
function location(ctx, node, location) {
264+
function createLocation(ctx, node, location) {
266265
const result = position(location)
267266

268267
if (node.type === 'element') {

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"@types/unist": "^2.0.0",
3939
"hastscript": "^7.0.0",
4040
"property-information": "^6.0.0",
41-
"vfile": "^4.0.0",
42-
"vfile-location": "^3.2.0",
41+
"vfile": "^5.0.0",
42+
"vfile-location": "^4.0.0",
4343
"web-namespaces": "^2.0.0"
4444
},
4545
"devDependencies": {

0 commit comments

Comments
 (0)