Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2751913
ve.dm.MWNowikiAnnotation.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ve.dm.MWNowikiAnnotation.js
View Options
/*!
* VisualEditor DataModel MWNowikiAnnotation class.
*
* @copyright See AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* DataModel MediaWiki nowiki annotation
*
* Represents `<nowiki>` tags (in HTML as `<span typeof="mw:Nowiki">`) and unwraps them when they change
* so as to retrigger Parsoid's escaping mechanism.
*
* @class
* @extends ve.dm.Annotation
* @constructor
* @param {Object} element [description]
*/
ve
.
dm
.
MWNowikiAnnotation
=
function
VeDmMWNowikiAnnotation
()
{
// Parent constructor
ve
.
dm
.
MWNowikiAnnotation
.
super
.
apply
(
this
,
arguments
);
};
/* Inheritance */
OO
.
inheritClass
(
ve
.
dm
.
MWNowikiAnnotation
,
ve
.
dm
.
Annotation
);
/* Static Properties */
ve
.
dm
.
MWNowikiAnnotation
.
static
.
name
=
'mwNowiki'
;
ve
.
dm
.
MWNowikiAnnotation
.
static
.
matchRdfaTypes
=
[
'mw:Nowiki'
];
ve
.
dm
.
MWNowikiAnnotation
.
static
.
toDomElements
=
function
(
dataElement
,
doc
,
converter
,
childDomElements
)
{
const
originalDomElements
=
converter
.
getStore
().
value
(
dataElement
.
originalDomElementsHash
),
originalChildren
=
originalDomElements
&&
originalDomElements
[
0
]
&&
originalDomElements
[
0
].
childNodes
,
domElement
=
document
.
createElement
(
'span'
);
let
contentsChanged
=
false
;
// Determine whether the contents changed
if
(
!
originalChildren
||
childDomElements
.
length
!==
originalChildren
.
length
)
{
contentsChanged
=
true
;
}
else
{
for
(
let
i
=
0
,
len
=
originalChildren
.
length
;
i
<
len
;
i
++
)
{
if
(
!
originalChildren
[
i
].
isEqualNode
(
childDomElements
[
i
]
)
)
{
contentsChanged
=
true
;
break
;
}
}
}
// If the contents changed, unwrap, otherwise, restore
if
(
contentsChanged
)
{
return
[];
}
domElement
.
setAttribute
(
'typeof'
,
'mw:Nowiki'
);
return
[
domElement
];
};
/* Registration */
ve
.
dm
.
modelRegistry
.
register
(
ve
.
dm
.
MWNowikiAnnotation
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 19:19 (1 d, 13 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6b/93/6b1e30b5dda26c8a486fbe0d6ec2
Default Alt Text
ve.dm.MWNowikiAnnotation.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment