@nativescript/core 9.1.4-next.0 → 9.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/application/application.ios.js +60 -96
- package/application/application.ios.js.map +1 -1
- package/application/scene-delegate-bridge.d.ts +1 -6
- package/application/scene-delegate-bridge.js +0 -16
- package/application/scene-delegate-bridge.js.map +1 -1
- package/config/config.interface.d.ts +46 -0
- package/fetch/index.d.ts +79 -0
- package/fetch/index.js +408 -0
- package/fetch/index.js.map +1 -0
- package/globals/index.js +1 -1
- package/globals/index.js.map +1 -1
- package/http/http-request-internal/index.ios.js +25 -12
- package/http/http-request-internal/index.ios.js.map +1 -1
- package/image-source/index.ios.js +6 -6
- package/image-source/index.ios.js.map +1 -1
- package/js-libs/easysax/easysax.d.ts +49 -7
- package/js-libs/easysax/easysax.js +631 -747
- package/js-libs/easysax/easysax.js.map +1 -0
- package/module-name-resolver/helpers.d.ts +1 -1
- package/module-name-resolver/index.d.ts +2 -2
- package/package.json +1 -1
- package/ui/animation/index.ios.js +2 -1
- package/ui/animation/index.ios.js.map +1 -1
- package/ui/builder/component-builder/index.d.ts +4 -4
- package/ui/builder/component-builder/index.js +1 -0
- package/ui/builder/component-builder/index.js.map +1 -1
- package/ui/builder/index.js.map +1 -1
- package/ui/core/bindable/expression-parser.d.ts +29 -0
- package/ui/core/bindable/expression-parser.js +2518 -0
- package/ui/core/bindable/expression-parser.js.map +1 -0
- package/ui/core/bindable/index.d.ts +1 -1
- package/ui/core/bindable/index.js.map +1 -1
- package/ui/core/properties/index.js +1 -0
- package/ui/core/properties/index.js.map +1 -1
- package/ui/core/view/index.android.js +12 -7
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/dialogs/index.ios.js +1 -1
- package/ui/dialogs/index.ios.js.map +1 -1
- package/ui/gestures/index.ios.js +6 -6
- package/ui/gestures/index.ios.js.map +1 -1
- package/ui/segmented-bar/index.android.d.ts +3 -1
- package/ui/segmented-bar/index.android.js +72 -2
- package/ui/segmented-bar/index.android.js.map +1 -1
- package/ui/segmented-bar/index.d.ts +15 -0
- package/ui/segmented-bar/segmented-bar-common.d.ts +2 -0
- package/ui/segmented-bar/segmented-bar-common.js +5 -0
- package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
- package/ui/styling/background-common.js +2 -2
- package/ui/styling/background-common.js.map +1 -1
- package/ui/styling/background.d.ts +1 -1
- package/ui/styling/background.ios.d.ts +1 -1
- package/ui/styling/background.ios.js +1 -1
- package/ui/styling/background.ios.js.map +1 -1
- package/ui/styling/style/index.d.ts +2 -2
- package/ui/styling/style/index.js.map +1 -1
- package/ui/tab-view/index.android.d.ts +5 -0
- package/ui/tab-view/index.android.js +84 -11
- package/ui/tab-view/index.android.js.map +1 -1
- package/ui/tab-view/index.d.ts +14 -0
- package/ui/tab-view/index.ios.js +2 -2
- package/ui/tab-view/index.ios.js.map +1 -1
- package/ui/tab-view/tab-navigation.android.d.ts +63 -0
- package/ui/tab-view/tab-navigation.android.js +380 -0
- package/ui/tab-view/tab-navigation.android.js.map +1 -0
- package/ui/tab-view/tab-view-common.d.ts +2 -0
- package/ui/tab-view/tab-view-common.js +5 -0
- package/ui/tab-view/tab-view-common.js.map +1 -1
- package/ui/text-base/index.ios.js +1 -1
- package/ui/text-base/index.ios.js.map +1 -1
- package/utils/native-helper-for-android.js +3 -1
- package/utils/native-helper-for-android.js.map +1 -1
- package/xhr/index.d.ts +5 -4
- package/xhr/index.js +14 -14
- package/xhr/index.js.map +1 -1
- package/xml/index.d.ts +2 -2
- package/fetch/index.mjs +0 -535
|
@@ -1,784 +1,668 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
parser.on('error', function(msg) {
|
|
14
|
-
//console.log(msg)
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
parser.on('startNode', function(elem, attr, uq, tagend, getStrNode) {
|
|
18
|
-
attr();
|
|
19
|
-
return;
|
|
20
|
-
if (tagend) {
|
|
21
|
-
console.log(' '+str)
|
|
22
|
-
} else {
|
|
23
|
-
console.log('+ '+str)
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
parser.on('endNode', function(elem, uq, tagstart, str) {
|
|
28
|
-
return;
|
|
29
|
-
if (!tagstart) console.log('- ' + str)
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
parser.on('textNode', function(s, uq) {
|
|
33
|
-
uq(s);
|
|
34
|
-
return
|
|
35
|
-
console.log(' '+s)
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
parser.on('cdata', function(data) {
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
parser.on('comment', function(text) {
|
|
43
|
-
//console.log('--'+text+'--')
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
//parser.on('question', function() {}); // <? ... ?>
|
|
47
|
-
//parser.on('attention', function() {}); // <!XXXXX zzzz="eeee">
|
|
48
|
-
|
|
49
|
-
console.time('easysax');
|
|
50
|
-
for(var z=1000;z--;) {
|
|
51
|
-
parser.parse(xml)
|
|
52
|
-
};
|
|
53
|
-
console.timeEnd('easysax');
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
// << ------------------------------------------------------------------------ >> //
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// if (typeof exports === 'object' /*&& this == exports*/) {
|
|
63
|
-
// module.exports.EasySAXParser = EasySAXParser;
|
|
64
|
-
// };
|
|
65
|
-
|
|
66
|
-
function EasySAXParser() {
|
|
67
|
-
'use strict';
|
|
68
|
-
|
|
69
|
-
if (!this) return null;
|
|
70
|
-
|
|
71
|
-
this.angularSyntax = false;
|
|
72
|
-
|
|
73
|
-
function nullFunc() {};
|
|
74
|
-
|
|
75
|
-
this.onTextNode = nullFunc;
|
|
76
|
-
this.onStartNode = nullFunc;
|
|
77
|
-
this.onEndNode = nullFunc;
|
|
78
|
-
this.onCDATA = nullFunc;
|
|
79
|
-
this.onError = nullFunc;
|
|
80
|
-
this.onComment = null;
|
|
81
|
-
this.onQuestion = null;
|
|
82
|
-
this.onAttention = null;
|
|
83
|
-
this.is_onComment = this.is_onQuestion = this.is_onAttention = false;
|
|
84
|
-
|
|
85
|
-
this.isNamespace = false;
|
|
86
|
-
this.useNS = null;
|
|
87
|
-
this.default_xmlns = null;
|
|
88
|
-
this.xmlns = null;
|
|
89
|
-
this.nsmatrix = {xmlns: this.xmlns};
|
|
90
|
-
this.hasSurmiseNS = false;
|
|
91
|
-
;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.attr_string = ''; // строка атрибутов
|
|
95
|
-
this.attr_posstart = 0; //
|
|
96
|
-
this.attr_res; // закешированный результат разбора атрибутов , null - разбор не проводился, object - хеш атрибутов, true - нет атрибутов, false - невалидный xml
|
|
1
|
+
// easysax 0.1.14, https://github.com/vflash/easysax
|
|
2
|
+
// Copyright (c) 2012 Vopilovskii Constantine, MIT License (see LICENSE in this folder).
|
|
3
|
+
function nullFunc() { }
|
|
4
|
+
// Clearing these handlers with `null` throws in easysax 0.1.14 (its fallback is out of scope there).
|
|
5
|
+
function handlerOrThrow(cb) {
|
|
6
|
+
if (!cb) {
|
|
7
|
+
throw new ReferenceError('nullFunc is not defined');
|
|
8
|
+
}
|
|
9
|
+
return cb;
|
|
97
10
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (root === v) ok = true;
|
|
128
|
-
x[i] = v;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
if (ok) {
|
|
133
|
-
this.isNamespace = true;
|
|
134
|
-
this.default_xmlns = root;
|
|
135
|
-
this.useNS = x;
|
|
136
|
-
};
|
|
11
|
+
// Shadows Object.prototype's names so `&constructor;` and friends decode to '\x01' instead of a builtin.
|
|
12
|
+
const xharsQuot = {
|
|
13
|
+
constructor: '',
|
|
14
|
+
hasOwnProperty: '',
|
|
15
|
+
isPrototypeOf: '',
|
|
16
|
+
propertyIsEnumerable: '',
|
|
17
|
+
toLocaleString: '',
|
|
18
|
+
toString: '',
|
|
19
|
+
valueOf: '',
|
|
20
|
+
quot: '"',
|
|
21
|
+
QUOT: '"',
|
|
22
|
+
amp: '&',
|
|
23
|
+
AMP: '&',
|
|
24
|
+
nbsp: '\u00A0',
|
|
25
|
+
apos: "'",
|
|
26
|
+
lt: '<',
|
|
27
|
+
LT: '<',
|
|
28
|
+
gt: '>',
|
|
29
|
+
GT: '>',
|
|
30
|
+
copy: '\u00A9',
|
|
31
|
+
laquo: '\u00AB',
|
|
32
|
+
raquo: '\u00BB',
|
|
33
|
+
reg: '\u00AE',
|
|
34
|
+
deg: '\u00B0',
|
|
35
|
+
plusmn: '\u00B1',
|
|
36
|
+
sup2: '\u00B2',
|
|
37
|
+
sup3: '\u00B3',
|
|
38
|
+
micro: '\u00B5',
|
|
39
|
+
para: '\u00B6',
|
|
137
40
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
EasySAXParser.prototype.parse = function(xml) {
|
|
141
|
-
if (typeof xml !== 'string') {
|
|
142
|
-
return;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
if (this.isNamespace) {
|
|
146
|
-
this.nsmatrix = {xmlns: this.default_xmlns};
|
|
147
|
-
|
|
148
|
-
parse(xml);
|
|
149
|
-
|
|
150
|
-
this.nsmatrix = false;
|
|
151
|
-
|
|
152
|
-
} else {
|
|
153
|
-
parse(xml);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
this.attr_res = true;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// -----------------------------------------------------
|
|
160
|
-
|
|
161
|
-
var xharsQuot={constructor: false, hasOwnProperty: false, isPrototypeOf: false, propertyIsEnumerable: false, toLocaleString: false, toString: false, valueOf: false
|
|
162
|
-
, quot: '"'
|
|
163
|
-
, QUOT: '"'
|
|
164
|
-
, amp: '&'
|
|
165
|
-
, AMP: '&'
|
|
166
|
-
, nbsp: '\u00A0'
|
|
167
|
-
, apos: '\''
|
|
168
|
-
, lt: '<'
|
|
169
|
-
, LT: '<'
|
|
170
|
-
, gt: '>'
|
|
171
|
-
, GT: '>'
|
|
172
|
-
, copy: '\u00A9'
|
|
173
|
-
, laquo: '\u00AB'
|
|
174
|
-
, raquo: '\u00BB'
|
|
175
|
-
, reg: '\u00AE'
|
|
176
|
-
, deg: '\u00B0'
|
|
177
|
-
, plusmn: '\u00B1'
|
|
178
|
-
, sup2: '\u00B2'
|
|
179
|
-
, sup3: '\u00B3'
|
|
180
|
-
, micro: '\u00B5'
|
|
181
|
-
, para: '\u00B6'
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
|
|
185
41
|
function rpEntities(s, d, x, z) {
|
|
186
42
|
if (z) {
|
|
187
43
|
return xharsQuot[z] || '\x01';
|
|
188
|
-
}
|
|
189
|
-
|
|
44
|
+
}
|
|
190
45
|
if (d) {
|
|
191
|
-
return String.fromCodePoint(d);
|
|
192
|
-
}
|
|
193
|
-
|
|
46
|
+
return String.fromCodePoint(Number(d));
|
|
47
|
+
}
|
|
194
48
|
return String.fromCodePoint(parseInt(x, 16));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
s = String(s);
|
|
49
|
+
}
|
|
50
|
+
function unEntities(value) {
|
|
51
|
+
let s = String(value);
|
|
199
52
|
if (s.length > 3 && s.indexOf('&') !== -1) {
|
|
200
|
-
if (s.indexOf('>') !== -1)
|
|
201
|
-
|
|
202
|
-
if (s.indexOf('&
|
|
203
|
-
|
|
53
|
+
if (s.indexOf('>') !== -1)
|
|
54
|
+
s = s.replace(/>/g, '>');
|
|
55
|
+
if (s.indexOf('<') !== -1)
|
|
56
|
+
s = s.replace(/</g, '<');
|
|
57
|
+
if (s.indexOf('"') !== -1)
|
|
58
|
+
s = s.replace(/"/g, '"');
|
|
204
59
|
if (s.indexOf('&') !== -1) {
|
|
205
|
-
s = s.replace(/&#(\d+);|&#x([0123456789abcdef]+);|&(\w+);/
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
60
|
+
s = s.replace(/&#(\d+);|&#x([0123456789abcdef]+);|&(\w+);/gi, rpEntities);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
209
63
|
return s;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
64
|
+
}
|
|
65
|
+
export class EasySAXParser {
|
|
66
|
+
constructor() {
|
|
67
|
+
this.angularSyntax = false;
|
|
68
|
+
this.onTextNode = nullFunc;
|
|
69
|
+
this.onStartNode = nullFunc;
|
|
70
|
+
this.onEndNode = nullFunc;
|
|
71
|
+
this.onCDATA = nullFunc;
|
|
72
|
+
this.onError = nullFunc;
|
|
73
|
+
this.onComment = null;
|
|
74
|
+
this.onQuestion = null;
|
|
75
|
+
this.onAttention = null;
|
|
76
|
+
this.is_onComment = false;
|
|
77
|
+
this.is_onQuestion = false;
|
|
78
|
+
this.is_onAttention = false;
|
|
79
|
+
this.isNamespace = false;
|
|
80
|
+
this.useNS = null;
|
|
81
|
+
this.default_xmlns = null;
|
|
82
|
+
this.xmlns = null;
|
|
83
|
+
// Not reset between parse() calls: a parse that stops inside a namespaced element leaves its scope behind.
|
|
84
|
+
this.nsmatrix = { xmlns: this.xmlns };
|
|
85
|
+
// Set while the start tag is pre-scanned for xmlns declarations, so getAttrs() applies them first.
|
|
86
|
+
this.hasSurmiseNS = false;
|
|
87
|
+
this.attr_string = '';
|
|
88
|
+
this.attr_posstart = 0;
|
|
225
89
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
EasySAXParser.prototype.getAttrs = function() {
|
|
237
|
-
if (this.attr_res !== null) {
|
|
238
|
-
return this.attr_res;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/*
|
|
242
|
-
if (xxtest !== u && attr_string.indexOf(xxtest) === -1) {
|
|
243
|
-
/ *
|
|
244
|
-
// для ускорения
|
|
245
|
-
if (getAttrs('html').type == 'html') {
|
|
246
|
-
...
|
|
247
|
-
};
|
|
248
|
-
* /
|
|
249
|
-
return true;
|
|
250
|
-
};
|
|
251
|
-
*/
|
|
252
|
-
|
|
253
|
-
var u
|
|
254
|
-
, res = {}
|
|
255
|
-
, s = this.attr_string
|
|
256
|
-
, i = this.attr_posstart
|
|
257
|
-
, l = s.length
|
|
258
|
-
, attr_list = this.hasSurmiseNS ? [] : false
|
|
259
|
-
, name, value = ''
|
|
260
|
-
, ok = false
|
|
261
|
-
, noValueAttribute = false
|
|
262
|
-
, j, w, nn, n
|
|
263
|
-
, hasNewMatrix
|
|
264
|
-
, alias, newalias
|
|
265
|
-
;
|
|
266
|
-
|
|
267
|
-
aa:
|
|
268
|
-
for(; i < l; i++) {
|
|
269
|
-
w = s.charCodeAt(i);
|
|
270
|
-
|
|
271
|
-
if (w===32 || (w<14 && w > 8) ) { // \f\n\r\t\v
|
|
272
|
-
continue
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
// Check for valid attribute start char
|
|
276
|
-
if ((w < 65 && !this.allowedAngularAttributeChars(w)) ||
|
|
277
|
-
w > 122 || (w > 90 && w < 97 && !this.allowedAngularAttributeChars(w)) ) { // ожидаем символ
|
|
278
|
-
return this.attr_res = false; // error. invalid char
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
for(j = i + 1; j < l; j++) { // проверяем все символы имени атрибута
|
|
282
|
-
w = s.charCodeAt(j);
|
|
283
|
-
|
|
284
|
-
if (w > 96 && w < 123 || w > 64 && w < 91 || w > 47 && w < 59 || w === 45 || w === 95 || w === 46 /* https://github.com/telerik/xPlatCore/issues/179 */) {
|
|
285
|
-
if (noValueAttribute) {
|
|
286
|
-
j--; //Started next attribute. Get back and break out of the loop.
|
|
287
|
-
break;
|
|
288
|
-
} else {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
if (this.allowedAngularAttributeChars(w)) {
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (w === 32 || (w > 8 && w < 14) ) { // \f\n\r\t\v пробел
|
|
298
|
-
noValueAttribute = true;
|
|
299
|
-
continue;
|
|
300
|
-
} else if (w === 61) { // "=" == 61
|
|
301
|
-
noValueAttribute = false;
|
|
90
|
+
on(name, cb) {
|
|
91
|
+
if (typeof cb !== 'function') {
|
|
92
|
+
if (cb !== null)
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
switch (name) {
|
|
96
|
+
case 'error':
|
|
97
|
+
this.onError = handlerOrThrow(cb);
|
|
302
98
|
break;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
99
|
+
case 'startNode':
|
|
100
|
+
this.onStartNode = handlerOrThrow(cb);
|
|
101
|
+
break;
|
|
102
|
+
case 'endNode':
|
|
103
|
+
this.onEndNode = handlerOrThrow(cb);
|
|
104
|
+
break;
|
|
105
|
+
case 'textNode':
|
|
106
|
+
this.onTextNode = handlerOrThrow(cb);
|
|
107
|
+
break;
|
|
108
|
+
case 'cdata':
|
|
109
|
+
this.onCDATA = handlerOrThrow(cb);
|
|
110
|
+
break;
|
|
111
|
+
case 'comment':
|
|
112
|
+
this.onComment = cb;
|
|
113
|
+
this.is_onComment = !!cb;
|
|
114
|
+
break;
|
|
115
|
+
// <? ... ?>
|
|
116
|
+
case 'question':
|
|
117
|
+
this.onQuestion = cb;
|
|
118
|
+
this.is_onQuestion = !!cb;
|
|
119
|
+
break;
|
|
120
|
+
// <!XXXXX zzzz="eeee">
|
|
121
|
+
case 'attention':
|
|
122
|
+
this.onAttention = cb;
|
|
123
|
+
this.is_onAttention = !!cb;
|
|
326
124
|
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Enables namespace resolution. `ns` maps namespace URIs to aliases; `root` must be one of the aliases.
|
|
129
|
+
* Elements outside a known namespace, and everything inside them, emit no events.
|
|
130
|
+
*/
|
|
131
|
+
ns(root, ns) {
|
|
132
|
+
if (!root || typeof root !== 'string' || !ns) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const x = {};
|
|
136
|
+
let ok = false;
|
|
137
|
+
for (const i in ns) {
|
|
138
|
+
const v = ns[i];
|
|
139
|
+
if (typeof v === 'string') {
|
|
140
|
+
if (root === v)
|
|
141
|
+
ok = true;
|
|
142
|
+
x[i] = v;
|
|
327
143
|
}
|
|
328
144
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
} else {
|
|
335
|
-
if (w === 39) {
|
|
336
|
-
j = s.indexOf('\'', i = j+2 );
|
|
337
|
-
|
|
338
|
-
} else { // "'"
|
|
339
|
-
return this.attr_res = false; // error. invalid char
|
|
340
|
-
};
|
|
341
|
-
};
|
|
145
|
+
if (ok) {
|
|
146
|
+
this.isNamespace = true;
|
|
147
|
+
this.default_xmlns = root;
|
|
148
|
+
this.useNS = x;
|
|
342
149
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (j+1 < l && !noValueAttribute) {
|
|
351
|
-
w = s.charCodeAt(j+1);
|
|
352
|
-
|
|
353
|
-
if (w > 32 || w < 9 || (w < 32 && w > 13)) {
|
|
354
|
-
// error. invalid char
|
|
355
|
-
//console.log('error 5')
|
|
356
|
-
return this.attr_res = false;
|
|
357
|
-
};
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
if (noValueAttribute) {
|
|
362
|
-
value = '';
|
|
363
|
-
} else {
|
|
364
|
-
value = s.substring(i, j);
|
|
150
|
+
}
|
|
151
|
+
allowedAngularAttributeChars(w) {
|
|
152
|
+
if (!this.angularSyntax) {
|
|
153
|
+
return false;
|
|
365
154
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (newalias = name === 'xmlns' ? 'xmlns' : name.charCodeAt(0) === 120 && name.substr(0, 6) === 'xmlns:' && name.substr(6) ) {
|
|
375
|
-
alias = this.useNS[unEntities(value)];
|
|
376
|
-
|
|
377
|
-
if (alias) {
|
|
378
|
-
if (this.nsmatrix[newalias] !== alias) {
|
|
379
|
-
if (!hasNewMatrix) {
|
|
380
|
-
hasNewMatrix = true;
|
|
381
|
-
nn = {}; for (n in this.nsmatrix) nn[n] = this.nsmatrix[n];
|
|
382
|
-
this.nsmatrix = nn;
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
this.nsmatrix[newalias] = alias;
|
|
386
|
-
};
|
|
387
|
-
} else {
|
|
388
|
-
if (this.nsmatrix[newalias]) {
|
|
389
|
-
if (!hasNewMatrix) {
|
|
390
|
-
hasNewMatrix = true;
|
|
391
|
-
nn = {}; for (n in this.nsmatrix) nn[n] = this.nsmatrix[n];
|
|
392
|
-
this.nsmatrix = nn;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
this.nsmatrix[newalias] = false;
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
res[name] = value;
|
|
400
|
-
continue;
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
attr_list.push(name, value);
|
|
404
|
-
continue;
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
w = name.length;
|
|
408
|
-
while(--w) {
|
|
409
|
-
if (name.charCodeAt(w) === 58) { // ':'
|
|
410
|
-
if (w = this.nsmatrix[name.substring(0, w)] ) {
|
|
411
|
-
res[w + name.substr(w)] = value;
|
|
412
|
-
};
|
|
413
|
-
continue aa;
|
|
414
|
-
|
|
415
|
-
// 'xml:base' ???
|
|
416
|
-
};
|
|
417
|
-
};
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
res[name] = value;
|
|
421
|
-
noValueAttribute = false;
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (!ok) {
|
|
426
|
-
return this.attr_res = true; // атрибутов нет, ошибок тоже нет
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
if (this.hasSurmiseNS) {
|
|
431
|
-
bb:
|
|
432
|
-
|
|
433
|
-
for (i = 0, l = attr_list.length; i < l; i++) {
|
|
434
|
-
name = attr_list[i++];
|
|
435
|
-
|
|
436
|
-
w = name.length;
|
|
437
|
-
while(--w) { // name.indexOf(':')
|
|
438
|
-
if (name.charCodeAt(w) === 58) { // ':'
|
|
439
|
-
if (w = this.nsmatrix[name.substring(0, w)]) {
|
|
440
|
-
res[w + name.substr(w)] = attr_list[i];
|
|
441
|
-
};
|
|
442
|
-
continue bb;
|
|
443
|
-
break;
|
|
444
|
-
};
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
res[name] = attr_list[i];
|
|
448
|
-
};
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
return this.attr_res = res;
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
// xml - string
|
|
456
|
-
EasySAXParser.prototype.parse = function(xml) {
|
|
457
|
-
var u
|
|
458
|
-
, xml = String(xml)
|
|
459
|
-
, nodestack = []
|
|
460
|
-
, stacknsmatrix = []
|
|
461
|
-
//, string_node
|
|
462
|
-
, elem
|
|
463
|
-
, tagend = false
|
|
464
|
-
, tagstart = false
|
|
465
|
-
, j = 0, i = 0, k = 0, len
|
|
466
|
-
, x, y, q, w
|
|
467
|
-
, xmlns
|
|
468
|
-
, stopIndex = 0
|
|
469
|
-
, stop // используется при разборе "namespace" . если встретился неизвестное пространство то события не генерируются
|
|
470
|
-
, _nsmatrix
|
|
471
|
-
, ok
|
|
472
|
-
, pos = 0, ln = 0, lnStart = -2, lnEnd = -1
|
|
473
|
-
;
|
|
474
|
-
|
|
475
|
-
len = xml.length;
|
|
476
|
-
function getStringNode() {
|
|
477
|
-
return xml.substring(i, j+1)
|
|
478
|
-
};
|
|
479
|
-
function findLineAndColumnFromPos() {
|
|
480
|
-
while (lnStart < lnEnd && lnEnd < pos) {
|
|
481
|
-
lnStart = lnEnd;
|
|
482
|
-
lnEnd = xml.indexOf("\n", lnEnd + 1);
|
|
483
|
-
++ln;
|
|
155
|
+
else {
|
|
156
|
+
return (w === 40 || // (
|
|
157
|
+
w === 41 || // )
|
|
158
|
+
w === 91 || // [
|
|
159
|
+
w === 93 || // ]
|
|
160
|
+
w === 94 || // ^
|
|
161
|
+
w === 35 // #
|
|
162
|
+
);
|
|
484
163
|
}
|
|
485
|
-
return { line: ln, column: pos - lnStart };
|
|
486
164
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
165
|
+
copyNsMatrix() {
|
|
166
|
+
const nn = {};
|
|
167
|
+
for (const n in this.nsmatrix)
|
|
168
|
+
nn[n] = this.nsmatrix[n];
|
|
169
|
+
return nn;
|
|
490
170
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Parses the current tag's attributes on demand, caching the result. Never throws:
|
|
173
|
+
* returns false on a parse error, true when there are no attributes, otherwise the hash.
|
|
174
|
+
*/
|
|
175
|
+
getAttrs() {
|
|
176
|
+
if (this.attr_res !== null) {
|
|
177
|
+
return this.attr_res;
|
|
178
|
+
}
|
|
179
|
+
const res = {};
|
|
180
|
+
const s = this.attr_string;
|
|
181
|
+
let i = this.attr_posstart;
|
|
182
|
+
const l = s.length;
|
|
183
|
+
const attr_list = [];
|
|
184
|
+
let name = '';
|
|
185
|
+
let value = '';
|
|
186
|
+
let ok = false;
|
|
187
|
+
let noValueAttribute = false;
|
|
188
|
+
let j = 0;
|
|
189
|
+
let w = 0;
|
|
190
|
+
let c = 0;
|
|
191
|
+
let prefixed = false;
|
|
192
|
+
let hasNewMatrix = false;
|
|
193
|
+
let alias = null;
|
|
194
|
+
let newalias = '';
|
|
195
|
+
for (; i < l; i++) {
|
|
196
|
+
w = s.charCodeAt(i);
|
|
197
|
+
if (w === 32 || (w < 14 && w > 8)) {
|
|
198
|
+
// \f\n\r\t\v
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if ((w < 65 && !this.allowedAngularAttributeChars(w)) || w > 122 || (w > 90 && w < 97 && !this.allowedAngularAttributeChars(w))) {
|
|
202
|
+
this.attr_res = false;
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
for (j = i + 1; j < l; j++) {
|
|
206
|
+
w = s.charCodeAt(j);
|
|
207
|
+
if ((w > 96 && w < 123) || (w > 64 && w < 91) || (w > 47 && w < 59) || w === 45 || w === 95 || w === 46 /* https://github.com/telerik/xPlatCore/issues/179 */) {
|
|
208
|
+
if (noValueAttribute) {
|
|
209
|
+
// The next attribute has started: step back so the outer loop picks it up.
|
|
210
|
+
j--;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (this.allowedAngularAttributeChars(w)) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (w === 32 || (w > 8 && w < 14)) {
|
|
221
|
+
noValueAttribute = true;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
else if (w === 61) {
|
|
225
|
+
// "="
|
|
226
|
+
noValueAttribute = false;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
if (!noValueAttribute) {
|
|
231
|
+
this.attr_res = false;
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
name = s.substring(i, j).trim();
|
|
238
|
+
ok = true;
|
|
239
|
+
if (name === 'xmlns:xmlns') {
|
|
240
|
+
this.attr_res = false;
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
w = s.charCodeAt(j + 1);
|
|
244
|
+
while (w === 32 || (w > 8 && w < 14)) {
|
|
245
|
+
j++;
|
|
246
|
+
w = s.charCodeAt(j + 1);
|
|
247
|
+
}
|
|
248
|
+
if (!noValueAttribute) {
|
|
249
|
+
if (w === 34) {
|
|
250
|
+
// '"'
|
|
251
|
+
i = j + 2;
|
|
252
|
+
j = s.indexOf('"', i);
|
|
253
|
+
}
|
|
254
|
+
else if (w === 39) {
|
|
255
|
+
// "'"
|
|
256
|
+
i = j + 2;
|
|
257
|
+
j = s.indexOf("'", i);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
this.attr_res = false;
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (j === -1) {
|
|
265
|
+
this.attr_res = false;
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (j + 1 < l && !noValueAttribute) {
|
|
269
|
+
w = s.charCodeAt(j + 1);
|
|
270
|
+
if (w > 32 || w < 9 || (w < 32 && w > 13)) {
|
|
271
|
+
this.attr_res = false;
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (noValueAttribute) {
|
|
276
|
+
value = '';
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
value = s.substring(i, j);
|
|
280
|
+
}
|
|
281
|
+
// The character after j was checked above, so the loop's i++ resumes past it.
|
|
496
282
|
i = j;
|
|
497
|
-
|
|
498
|
-
|
|
283
|
+
if (this.isNamespace) {
|
|
284
|
+
if (this.hasSurmiseNS) {
|
|
285
|
+
// Pre-scan: apply xmlns declarations first, resolve the other names after the loop.
|
|
286
|
+
newalias = '';
|
|
287
|
+
if (name === 'xmlns') {
|
|
288
|
+
newalias = 'xmlns';
|
|
289
|
+
}
|
|
290
|
+
else if (name.charCodeAt(0) === 120 && name.substr(0, 6) === 'xmlns:') {
|
|
291
|
+
newalias = name.substr(6);
|
|
292
|
+
}
|
|
293
|
+
if (newalias) {
|
|
294
|
+
alias = this.useNS[unEntities(value)];
|
|
295
|
+
if (alias) {
|
|
296
|
+
if (this.nsmatrix[newalias] !== alias) {
|
|
297
|
+
if (!hasNewMatrix) {
|
|
298
|
+
hasNewMatrix = true;
|
|
299
|
+
this.nsmatrix = this.copyNsMatrix();
|
|
300
|
+
}
|
|
301
|
+
this.nsmatrix[newalias] = alias;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
if (this.nsmatrix[newalias]) {
|
|
306
|
+
if (!hasNewMatrix) {
|
|
307
|
+
hasNewMatrix = true;
|
|
308
|
+
this.nsmatrix = this.copyNsMatrix();
|
|
309
|
+
}
|
|
310
|
+
this.nsmatrix[newalias] = false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
res[name] = value;
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
attr_list.push(name, value);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
// Kept as `--c !== 0`: an empty name (possible only with ns()) never ends this loop, as in easysax 0.1.14.
|
|
320
|
+
prefixed = false;
|
|
321
|
+
c = name.length;
|
|
322
|
+
while (--c !== 0) {
|
|
323
|
+
if (name.charCodeAt(c) === 58) {
|
|
324
|
+
// ':'
|
|
325
|
+
alias = this.nsmatrix[name.substring(0, c)];
|
|
326
|
+
if (alias) {
|
|
327
|
+
// substr() coerces the alias to a number (NaN -> 0), so the key keeps the prefixed name.
|
|
328
|
+
res[alias + name.substr(Number(alias))] = value;
|
|
329
|
+
}
|
|
330
|
+
prefixed = true;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (prefixed) {
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
res[name] = value;
|
|
339
|
+
noValueAttribute = false;
|
|
340
|
+
}
|
|
341
|
+
if (!ok) {
|
|
342
|
+
this.attr_res = true;
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
if (this.hasSurmiseNS) {
|
|
346
|
+
for (let k = 0, kl = attr_list.length; k < kl; k++) {
|
|
347
|
+
name = attr_list[k++];
|
|
348
|
+
prefixed = false;
|
|
349
|
+
c = name.length;
|
|
350
|
+
while (--c !== 0) {
|
|
351
|
+
if (name.charCodeAt(c) === 58) {
|
|
352
|
+
// ':'
|
|
353
|
+
alias = this.nsmatrix[name.substring(0, c)];
|
|
354
|
+
if (alias) {
|
|
355
|
+
res[alias + name.substr(Number(alias))] = attr_list[k];
|
|
356
|
+
}
|
|
357
|
+
prefixed = true;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (prefixed) {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
res[name] = attr_list[k];
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
this.attr_res = res;
|
|
368
|
+
return res;
|
|
369
|
+
}
|
|
370
|
+
parse(input) {
|
|
371
|
+
const xml = String(input);
|
|
372
|
+
const nodestack = [];
|
|
373
|
+
const stacknsmatrix = [];
|
|
374
|
+
let elem = '';
|
|
375
|
+
let tagend = false;
|
|
376
|
+
let tagstart = false;
|
|
377
|
+
let j = 0;
|
|
378
|
+
let i = 0;
|
|
379
|
+
let k = 0;
|
|
380
|
+
let x = '';
|
|
381
|
+
let y = 0;
|
|
382
|
+
let q = 0;
|
|
383
|
+
let w = 0;
|
|
384
|
+
let c = 0;
|
|
385
|
+
let inside = 0;
|
|
386
|
+
let xmlns = null;
|
|
387
|
+
let stopIndex = 0;
|
|
388
|
+
// Inside an element of an unknown namespace: no events until it closes.
|
|
389
|
+
let stop = false;
|
|
390
|
+
let _nsmatrix = this.nsmatrix;
|
|
391
|
+
let ok = undefined;
|
|
392
|
+
let pos = 0;
|
|
393
|
+
let ln = 0;
|
|
394
|
+
let lnStart = -2;
|
|
395
|
+
let lnEnd = -1;
|
|
396
|
+
const len = xml.length;
|
|
397
|
+
// Handlers may call these later; they read the parser's state at call time.
|
|
398
|
+
const getStringNode = () => {
|
|
399
|
+
return xml.substring(i, j + 1);
|
|
499
400
|
};
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
return;
|
|
401
|
+
const findLineAndColumnFromPos = () => {
|
|
402
|
+
while (lnStart < lnEnd && lnEnd < pos) {
|
|
403
|
+
lnStart = lnEnd;
|
|
404
|
+
lnEnd = xml.indexOf('\n', lnEnd + 1);
|
|
405
|
+
++ln;
|
|
406
|
+
}
|
|
407
|
+
return { line: ln, column: pos - lnStart };
|
|
509
408
|
};
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (ok === false) return;
|
|
409
|
+
const position = (p) => {
|
|
410
|
+
pos = p;
|
|
411
|
+
return findLineAndColumnFromPos;
|
|
514
412
|
};
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
//x = xml.substring(i+9, j);
|
|
528
|
-
if (!stop) {
|
|
529
|
-
ok = this.onCDATA(xml.substring(i+9, j), false, position(i));
|
|
530
|
-
if (ok === false) return;
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
j += 3;
|
|
534
|
-
continue;
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
if (w === 45 && xml.charCodeAt(i+3) === 45) { // 45 == "-"
|
|
538
|
-
j = xml.indexOf('-->', i);
|
|
539
|
-
if (j === -1) {
|
|
540
|
-
this.onError('expected -->', position(i));
|
|
413
|
+
while (j !== -1) {
|
|
414
|
+
stop = stopIndex > 0;
|
|
415
|
+
if (xml.charCodeAt(j) === 60) {
|
|
416
|
+
// "<"
|
|
417
|
+
i = j;
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
i = xml.indexOf('<', j);
|
|
421
|
+
}
|
|
422
|
+
if (i === -1) {
|
|
423
|
+
if (nodestack.length) {
|
|
424
|
+
this.onError('end file', position(j));
|
|
541
425
|
return;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (this.is_onComment && !stop) {
|
|
546
|
-
ok = this.onComment(xml.substring(i+4, j), unEntities, position(i));
|
|
547
|
-
if (ok === false) return;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
j += 3;
|
|
551
|
-
continue;
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
j = xml.indexOf('>', i+1);
|
|
555
|
-
if (j === -1) {
|
|
556
|
-
this.onError('expected ">"', position(i + 1));
|
|
426
|
+
}
|
|
557
427
|
return;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (ok === false) return;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
j += 1;
|
|
566
|
-
continue;
|
|
567
|
-
|
|
568
|
-
} else {
|
|
569
|
-
if (w === 63) { // "?"
|
|
570
|
-
j = xml.indexOf('?>', i);
|
|
571
|
-
if (j === -1) { // error
|
|
572
|
-
this.onError('...?>', position(i));
|
|
428
|
+
}
|
|
429
|
+
if (j !== i && !stop) {
|
|
430
|
+
ok = this.onTextNode(xml.substring(j, i), unEntities, position(j));
|
|
431
|
+
if (ok === false)
|
|
573
432
|
return;
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
433
|
+
}
|
|
434
|
+
w = xml.charCodeAt(i + 1);
|
|
435
|
+
if (w === 33) {
|
|
436
|
+
// "!"
|
|
437
|
+
w = xml.charCodeAt(i + 2);
|
|
438
|
+
if (w === 91 && xml.substr(i + 3, 6) === 'CDATA[') {
|
|
439
|
+
// "["
|
|
440
|
+
j = xml.indexOf(']]>', i);
|
|
441
|
+
if (j === -1) {
|
|
442
|
+
this.onError('cdata', position(i));
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (!stop) {
|
|
446
|
+
ok = this.onCDATA(xml.substring(i + 9, j), false, position(i));
|
|
447
|
+
if (ok === false)
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
j += 3;
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (w === 45 && xml.charCodeAt(i + 3) === 45) {
|
|
454
|
+
// "-"
|
|
455
|
+
j = xml.indexOf('-->', i);
|
|
456
|
+
if (j === -1) {
|
|
457
|
+
this.onError('expected -->', position(i));
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
if (this.is_onComment && !stop) {
|
|
461
|
+
ok = this.onComment(xml.substring(i + 4, j), unEntities, position(i));
|
|
462
|
+
if (ok === false)
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
j += 3;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
j = xml.indexOf('>', i + 1);
|
|
469
|
+
if (j === -1) {
|
|
470
|
+
this.onError('expected ">"', position(i + 1));
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (this.is_onAttention && !stop) {
|
|
474
|
+
ok = this.onAttention(xml.substring(i, j + 1), unEntities, position(i));
|
|
475
|
+
if (ok === false)
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
j += 1;
|
|
582
479
|
continue;
|
|
583
|
-
};
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
var inside=false;
|
|
587
|
-
for (k=i,j=-1;k<len;k++) {
|
|
588
|
-
var c = xml.charCodeAt(k);
|
|
589
|
-
if (!inside) {
|
|
590
|
-
|
|
591
|
-
if (c === 34) { // '"'
|
|
592
|
-
inside = c;
|
|
593
|
-
}
|
|
594
|
-
else if (c === 39) { // "'"
|
|
595
|
-
inside = c;
|
|
596
|
-
}
|
|
597
|
-
else if (c === 62) { // <
|
|
598
|
-
j = k; break;
|
|
599
|
-
}
|
|
600
|
-
} else {
|
|
601
|
-
if (c === inside) { inside = false; }
|
|
602
480
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
// проверяем что должен быть закрыт тотже тег что и открывался
|
|
618
|
-
x = elem = nodestack.pop();
|
|
619
|
-
q = i + 2 + x.length;
|
|
620
|
-
|
|
621
|
-
//console.log()
|
|
622
|
-
if (xml.substring(i+2, q) !== x) {
|
|
623
|
-
this.onError('close tagname', position(i + 2));
|
|
624
|
-
return;
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
// проверим что в закрываюшем теге нет лишнего
|
|
628
|
-
for(; q < j; q++) {
|
|
629
|
-
w = xml.charCodeAt(q);
|
|
630
|
-
|
|
631
|
-
if (w===32 || (w > 8 && w<14) ) { // \f\n\r\t\v пробел
|
|
481
|
+
else {
|
|
482
|
+
if (w === 63) {
|
|
483
|
+
// "?"
|
|
484
|
+
j = xml.indexOf('?>', i);
|
|
485
|
+
if (j === -1) {
|
|
486
|
+
this.onError('...?>', position(i));
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (this.is_onQuestion) {
|
|
490
|
+
ok = this.onQuestion(xml.substring(i, j + 2), position(i));
|
|
491
|
+
if (ok === false)
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
j += 2;
|
|
632
495
|
continue;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
// The tag ends at the first '>' outside a quoted attribute value.
|
|
499
|
+
inside = 0;
|
|
500
|
+
for (k = i, j = -1; k < len; k++) {
|
|
501
|
+
c = xml.charCodeAt(k);
|
|
502
|
+
if (inside === 0) {
|
|
503
|
+
if (c === 34) {
|
|
504
|
+
// '"'
|
|
505
|
+
inside = c;
|
|
506
|
+
}
|
|
507
|
+
else if (c === 39) {
|
|
508
|
+
// "'"
|
|
509
|
+
inside = c;
|
|
510
|
+
}
|
|
511
|
+
else if (c === 62) {
|
|
512
|
+
// ">"
|
|
513
|
+
j = k;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
if (c === inside) {
|
|
519
|
+
inside = 0;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
if (j === -1) {
|
|
524
|
+
this.onError('...>', position(i + 1));
|
|
636
525
|
return;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
tagstart = true;
|
|
526
|
+
}
|
|
527
|
+
this.attr_res = true;
|
|
528
|
+
if (w === 47) {
|
|
529
|
+
// </...
|
|
530
|
+
tagstart = false;
|
|
644
531
|
tagend = true;
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
532
|
+
const opened = nodestack.pop();
|
|
533
|
+
if (opened === undefined) {
|
|
534
|
+
// A close tag with nothing open throws in easysax 0.1.14.
|
|
535
|
+
throw new TypeError("Cannot read properties of undefined (reading 'length')");
|
|
536
|
+
}
|
|
537
|
+
x = elem = opened;
|
|
538
|
+
q = i + 2 + x.length;
|
|
539
|
+
if (xml.substring(i + 2, q) !== x) {
|
|
540
|
+
this.onError('close tagname', position(i + 2));
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
for (; q < j; q++) {
|
|
544
|
+
w = xml.charCodeAt(q);
|
|
545
|
+
if (w === 32 || (w > 8 && w < 14)) {
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
this.onError('close tag', position(i + 2));
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
if (xml.charCodeAt(j - 1) === 47) {
|
|
554
|
+
// .../>
|
|
555
|
+
x = elem = xml.substring(i + 1, j - 1);
|
|
556
|
+
tagstart = true;
|
|
557
|
+
tagend = true;
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
x = elem = xml.substring(i + 1, j);
|
|
561
|
+
tagstart = true;
|
|
562
|
+
tagend = false;
|
|
563
|
+
}
|
|
564
|
+
if (!((w > 96 && w < 123) || (w > 64 && w < 91))) {
|
|
565
|
+
this.onError('first char nodeName', position(i + 1));
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
for (q = 1, y = x.length; q < y; q++) {
|
|
569
|
+
w = x.charCodeAt(q);
|
|
570
|
+
if ((w > 96 && w < 123) || (w > 64 && w < 91) || (w > 47 && w < 59) || w === 45 || w === 95 || w === 46 /* https://github.com/telerik/xPlatCore/issues/179 */) {
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
if (w === 32 || (w < 14 && w > 8)) {
|
|
574
|
+
elem = x.substring(0, q);
|
|
575
|
+
// The tag may have attributes.
|
|
576
|
+
this.attr_res = null;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
this.onError('invalid nodeName', position(i + 1));
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
if (!tagend) {
|
|
583
|
+
nodestack.push(elem);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
if (this.isNamespace) {
|
|
587
|
+
if (stop) {
|
|
588
|
+
if (tagend) {
|
|
589
|
+
if (!tagstart) {
|
|
590
|
+
if (--stopIndex === 0) {
|
|
591
|
+
this.nsmatrix = stacknsmatrix.pop();
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
stopIndex += 1;
|
|
597
|
+
}
|
|
598
|
+
j += 1;
|
|
661
599
|
continue;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
if (
|
|
665
|
-
|
|
666
|
-
this.attr_res
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
600
|
+
}
|
|
601
|
+
_nsmatrix = this.nsmatrix;
|
|
602
|
+
if (!tagend) {
|
|
603
|
+
stacknsmatrix.push(this.nsmatrix);
|
|
604
|
+
if (this.attr_res !== true) {
|
|
605
|
+
this.hasSurmiseNS = x.indexOf('xmlns', q) !== -1;
|
|
606
|
+
if (this.hasSurmiseNS) {
|
|
607
|
+
this.attr_string = x;
|
|
608
|
+
this.attr_posstart = q;
|
|
609
|
+
this.getAttrs();
|
|
610
|
+
this.hasSurmiseNS = false;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
w = elem.indexOf(':');
|
|
615
|
+
if (w !== -1) {
|
|
616
|
+
xmlns = this.nsmatrix[elem.substring(0, w)];
|
|
617
|
+
elem = elem.substr(w + 1);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
xmlns = this.nsmatrix.xmlns;
|
|
621
|
+
}
|
|
622
|
+
if (!xmlns) {
|
|
623
|
+
if (tagend) {
|
|
624
|
+
if (tagstart) {
|
|
625
|
+
this.nsmatrix = _nsmatrix;
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
685
628
|
this.nsmatrix = stacknsmatrix.pop();
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
};
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
w = elem.indexOf(':');
|
|
717
|
-
if (w !== -1) {
|
|
718
|
-
xmlns = this.nsmatrix[elem.substring(0, w)];
|
|
719
|
-
elem = elem.substr(w+1);
|
|
720
|
-
|
|
721
|
-
} else {
|
|
722
|
-
xmlns = this.nsmatrix.xmlns;
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
if (!xmlns) {
|
|
726
|
-
if (tagend) {
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
// The first element whose namespace is unknown.
|
|
633
|
+
stopIndex = 1;
|
|
634
|
+
this.attr_res = true;
|
|
635
|
+
}
|
|
636
|
+
j += 1;
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
elem = xmlns + ':' + elem;
|
|
640
|
+
}
|
|
641
|
+
if (tagstart) {
|
|
642
|
+
this.attr_string = x;
|
|
643
|
+
this.attr_posstart = q;
|
|
644
|
+
ok = this.onStartNode(elem, () => this.getAttrs(), unEntities, tagend, getStringNode, position(i));
|
|
645
|
+
if (ok === false) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
this.attr_res = true;
|
|
649
|
+
}
|
|
650
|
+
if (tagend) {
|
|
651
|
+
ok = this.onEndNode(elem, unEntities, tagstart, getStringNode, position(i));
|
|
652
|
+
if (ok === false) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (this.isNamespace) {
|
|
727
656
|
if (tagstart) {
|
|
728
657
|
this.nsmatrix = _nsmatrix;
|
|
729
|
-
}
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
730
660
|
this.nsmatrix = stacknsmatrix.pop();
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
elem = xmlns + ':' + elem;
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
//string_node = xml.substring(i, j+1); // текст ноды как есть
|
|
745
|
-
|
|
746
|
-
if (tagstart) { // is_onStartNode
|
|
747
|
-
this.attr_string = x;
|
|
748
|
-
this.attr_posstart = q;
|
|
749
|
-
|
|
750
|
-
var that = this;
|
|
751
|
-
ok = this.onStartNode(elem, function() { return that.getAttrs() }, unEntities, tagend
|
|
752
|
-
, getStringNode, position(i)
|
|
753
|
-
);
|
|
754
|
-
|
|
755
|
-
if (ok === false) {
|
|
756
|
-
return;
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
this.attr_res = true;
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
if (tagend) {
|
|
763
|
-
ok = this.onEndNode(elem, unEntities, tagstart
|
|
764
|
-
, getStringNode, position(i)
|
|
765
|
-
);
|
|
766
|
-
|
|
767
|
-
if (ok === false) {
|
|
768
|
-
return;
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
if (this.isNamespace) {
|
|
772
|
-
if (tagstart) {
|
|
773
|
-
this.nsmatrix = _nsmatrix;
|
|
774
|
-
} else {
|
|
775
|
-
this.nsmatrix = stacknsmatrix.pop();
|
|
776
|
-
};
|
|
777
|
-
};
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
j += 1;
|
|
781
|
-
};
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
export { EasySAXParser };
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
j += 1;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
//# sourceMappingURL=easysax.js.map
|