@@ -10,11 +10,11 @@ var comment = require('./comment');
1010
1111/**
1212 * Generic node object (inherited by all objects)
13- *
13+ *
1414 * @public @constructor {node }
1515 * @param {node } parent The parent node
1616 * @param {array } ast The current AST node
17- *
17+ *
1818 * @property {node } parent Parent node instance
1919 * @property {relation[] } relations {@link RELATION.md|:link: } List of linked nodes
2020 * @property {position|null } position {@link POSITION.md|:link: } Current node position
@@ -32,24 +32,8 @@ var node = function(parent, ast) {
3232 this . relations = [ ] ;
3333
3434 // check if contains a position node
35- if ( ast [ 0 ] === 'position' ) {
36- this . position = new position ( ast ) ;
37- ast = ast [ 3 ] ;
38- }
39- // check if doc block with inner component
40- if ( ast [ 0 ] === 'doc' && ast . length === 3 ) {
41- this . doc = comment . create ( this , ast ) ;
42- ast = ast [ 2 ] ;
43- if ( this . position ) {
44- // attach position node to comment
45- this . doc . position = this . position ;
46- if ( ast [ 0 ] === 'position' ) {
47- this . position = new position ( ast ) ;
48- ast = ast [ 3 ] ;
49- } else {
50- delete this . position ;
51- }
52- }
35+ if ( ast . loc ) {
36+ this . position = new position ( ast . loc ) ;
5337 }
5438
5539 if ( this . type !== 'file' ) {
@@ -223,30 +207,30 @@ node.prototype.export = function() {
223207
224208/**
225209 * Use this function to extend a node into a specific object.
226- *
210+ *
227211 * In order to make the cache wording automatically, the class
228212 * name must be the same as the filename `foo` class into `./foo.js`
229- *
213+ *
230214 * *WARNING* : It you pass a constructor, make sur it's named in order to
231215 * automatically retrieve it's classname (used by the caching system)
232- *
216+ *
233217 * @public
234218 * @param {constructor|string } ctor Define the named constructor, or the class name
235219 * @return {constructor }
236- *
220+ *
237221 * @example Create with a constructor
238222 * var block = require('./block');
239223 * var child = block.extends(function className(parent, ast) {
240224 * block.apply(this, [parent, ast]);
241225 * // customized init code
242226 * });
243227 * child.prototype.foo = function() ...
244- *
228+ *
245229 * @example Create with a generic class name
246230 * var block = require('./block');
247231 * var child = block.extends('className');
248232 * child.prototype.foo = function() ...
249- *
233+ *
250234 */
251235node . extends = declareExtends ( node ) ;
252236
@@ -296,4 +280,4 @@ function declareExtends(base) {
296280}
297281;
298282
299- module . exports = node ;
283+ module . exports = node ;
0 commit comments