Skip to content

Commit

Permalink
Update vfile-location
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 23, 2021
1 parent 8df84b7 commit 762ba62
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @typedef {import('vfile').VFile} VFile
* @typedef {import('vfile-location').Location} VFileLocation
* @typedef {import('property-information').Schema} Schema
* @typedef {import('unist').Position} Position
* @typedef {import('unist').Point} Point
Expand Down Expand Up @@ -45,7 +44,7 @@

import {h, s} from 'hastscript'
import {html, svg, find} from 'property-information'
import vfileLocation from 'vfile-location'
import {location} from 'vfile-location'
import {webNamespaces} from 'web-namespaces'

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

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

if (position) {
ctx.location = true
Expand Down Expand Up @@ -170,10 +169,10 @@ function root(ctx, ast, children) {

if (ctx.file && ctx.location) {
const doc = String(ctx.file)
const location = vfileLocation(doc)
const loc = location(doc)
result.position = {
start: location.toPoint(0),
end: location.toPoint(doc.length)
start: loc.toPoint(0),
end: loc.toPoint(doc.length)
}
}

Expand Down Expand Up @@ -262,7 +261,7 @@ function element(ctx, ast, children) {
* @param {P5ElementLocation} location
* @returns {Position|null}
*/
function location(ctx, node, location) {
function createLocation(ctx, node, location) {
const result = position(location)

if (node.type === 'element') {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"@types/unist": "^2.0.0",
"hastscript": "^7.0.0",
"property-information": "^6.0.0",
"vfile": "^4.0.0",
"vfile-location": "^3.2.0",
"vfile": "^5.0.0",
"vfile-location": "^4.0.0",
"web-namespaces": "^2.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit 762ba62

Please sign in to comment.