@@ -16,14 +16,14 @@ class RSSParser {
16
16
'/Channel/items'
17
17
] ;
18
18
19
- static parseItem ( node , feed ) {
19
+ static parseItem ( node , ctxt ) {
20
20
let item = new Item ( {
21
- title : XPath . lookup ( node , 'title' ) ,
22
- description : XPath . lookup ( node , 'description' ) ,
23
- source : XPath . lookup ( node , 'link' ) ,
21
+ title : XPath . lookup ( node , 'title' ) ,
22
+ description : XPath . lookup ( node , 'description' ) ,
23
+ source : XPath . lookup ( node , 'link' ) ,
24
24
// RSS 2.0 only
25
- sourceId : XPath . lookup ( node , 'guid' ) ,
26
- time : DateParser . parse ( XPath . lookup ( node , 'pubDate' ) )
25
+ sourceId : XPath . lookup ( node , 'guid' ) ,
26
+ time : DateParser . parse ( XPath . lookup ( node , 'pubDate' ) )
27
27
} ) ;
28
28
29
29
XPath . foreach ( node , 'enclosure' , ( n ) =>
@@ -33,9 +33,9 @@ class RSSParser {
33
33
)
34
34
) ;
35
35
36
- NamespaceParser . parseItem ( node , [ 'dc' , 'content' , 'media' ] , feed , item ) ;
36
+ NamespaceParser . parseItem ( ctxt . root , node , item ) ;
37
37
38
- feed . addItem ( item ) ;
38
+ ctxt . feed . addItem ( item ) ;
39
39
}
40
40
41
41
static parse ( str ) {
@@ -52,7 +52,7 @@ class RSSParser {
52
52
feed . description = XPath . lookup ( root , '/Channel/description' ) ;
53
53
feed . homepage = XPath . lookup ( root , '/Channel/link' ) ;
54
54
55
- XPath . foreach ( root , '/Channel/items/item' , this . parseItem , feed ) ;
55
+ XPath . foreach ( root , '/Channel/items/item' , this . parseItem , { root , feed } ) ;
56
56
}
57
57
58
58
// RSS 2.0
@@ -61,7 +61,7 @@ class RSSParser {
61
61
feed . description = XPath . lookup ( root , '/rss/channel/description' ) ;
62
62
feed . homepage = XPath . lookup ( root , '/rss/channel/link' ) ;
63
63
64
- XPath . foreach ( root , '/rss/channel/item' , this . parseItem , feed ) ;
64
+ XPath . foreach ( root , '/rss/channel/item' , this . parseItem , { root , feed } ) ;
65
65
}
66
66
67
67
return feed ;
0 commit comments