Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
test_task
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Дмитрий Никулин
test_task
Commits
be8a4aca
Commit
be8a4aca
authored
Feb 04, 2016
by
Dmitry
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Исправлена проблема с регистром тегов при сериализации
parent
56fb7860
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
9 deletions
+27
-9
jsdom.js
node_modules/jsdom/lib/jsdom.js
+2
-2
documentAdapter.js
node_modules/jsdom/lib/jsdom/browser/documentAdapter.js
+5
-1
domtohtml.js
node_modules/jsdom/lib/jsdom/browser/domtohtml.js
+10
-4
svg_dom.js
svg_dom.js
+10
-2
No files found.
node_modules/jsdom/lib/jsdom.js
View file @
be8a4aca
...
...
@@ -244,8 +244,8 @@ exports.env = exports.jsdom.env = function () {
return
req
;
};
exports
.
serializeDocument
=
function
(
doc
)
{
return
domToHtml
([
doc
]);
exports
.
serializeDocument
=
function
(
doc
,
lowerCaseTagNames
)
{
return
domToHtml
([
doc
]
,
lowerCaseTagNames
);
};
function
processHTML
(
config
)
{
...
...
node_modules/jsdom/lib/jsdom/browser/documentAdapter.js
View file @
be8a4aca
...
...
@@ -3,6 +3,10 @@
const
idlUtils
=
require
(
"../living/generated/utils"
);
class
DocumentAdapter
{
constructor
(
lowerCaseTagNames
){
this
.
lowerCaseTagNames
=
lowerCaseTagNames
;
}
getFirstChild
(
node
)
{
return
node
.
childNodes
[
0
];
}
...
...
@@ -28,7 +32,7 @@ class DocumentAdapter {
// Node data
getTagName
(
element
)
{
return
element
.
tagName
.
toLowerCase
()
;
return
this
.
lowerCaseTagNames
?
element
.
tagName
.
toLowerCase
():
element
.
tagName
;
}
getNamespaceURI
(
element
)
{
...
...
node_modules/jsdom/lib/jsdom/browser/domtohtml.js
View file @
be8a4aca
"use strict"
;
const
parse5
=
require
(
"parse5"
);
const
d
ocumentAdapter
=
require
(
"./documentAdapter"
);
const
D
ocumentAdapter
=
require
(
"./documentAdapter"
);
const
NODE_TYPE
=
require
(
"../living/node-type"
);
const
idlUtils
=
require
(
"../living/generated/utils"
);
const
serializer
=
new
parse5
.
TreeSerializer
(
documentAdapter
);
exports
.
domToHtml
=
function
(
iterable
)
{
exports
.
domToHtml
=
function
(
iterable
,
lowerCaseTagNames
)
{
// Если явно не указано, то true
if
(
typeof
lowerCaseTagNames
===
'undefined'
)
{
lowerCaseTagNames
=
true
;
}
var
documentAdapter
=
new
DocumentAdapter
(
lowerCaseTagNames
);
var
serializer
=
new
parse5
.
TreeSerializer
(
documentAdapter
);
let
ret
=
""
;
for
(
const
node
of
iterable
)
{
if
(
node
.
nodeType
===
NODE_TYPE
.
DOCUMENT_NODE
)
{
...
...
@@ -16,4 +21,4 @@ exports.domToHtml = function (iterable) {
}
}
return
ret
;
};
};
\ No newline at end of file
svg_dom.js
View file @
be8a4aca
...
...
@@ -16,8 +16,16 @@ function loadCompleteCallback(err, window){
if
(
err
){
console
.
error
(
"Произошла ошибка при загрузке DOM: "
+
err
.
toString
());
}
else
{
// Сериализируем DOM в строку
var
serializedSvg
=
jsdom
.
serializeDocument
(
window
.
document
);
/* Сериализируем DOM в строку.
* Опытным путем было выяснено, что регистр "портится" при сериализации.
* В код jsdom внесены изменения: теперь serializeDocument принимает
* необязательный аргумент, отвечающий за перевод имен тегов в нижний
* регистр. Если он не указан или же его значение равно true, то
* serializeDocument ведет себя так же, как и ранее. Если этот параметр
* равен false, то имена тегов не переводятся в нижний регистр.
* В данном случае требуется не переводить имена тегов в нижний регистр,
* поэтому передаем false вторым аргументом. */
var
serializedSvg
=
jsdom
.
serializeDocument
(
window
.
document
,
false
);
try
{
fs
.
writeFileSync
(
OUTPUT_FILE
,
serializedSvg
);
...
...
Дмитрий Никулин
@TheOwl
mentioned in commit
9ab97c3b
·
Feb 04, 2016
mentioned in commit
9ab97c3b
mentioned in commit 9ab97c3b7cd3829a011bae94f604cc4ba86be8bf
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment