Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
272411dd
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
272411dd
编写于
12月 25, 2017
作者:
D
Don McCurdy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PropertyBinding: Allow unicode node names.
上级
092d2c0b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
60 addition
and
14 deletion
+60
-14
src/animation/PropertyBinding.js
src/animation/PropertyBinding.js
+22
-11
test/unit/src/animation/PropertyBinding.tests.js
test/unit/src/animation/PropertyBinding.tests.js
+38
-3
未找到文件。
src/animation/PropertyBinding.js
浏览文件 @
272411dd
...
...
@@ -8,6 +8,9 @@
* @author tschw
*/
// Characters [].:/ are reserved for track binding syntax.
var
RESERVED_CHARS_RE
=
'
\\
[
\\
]
\\
.:
\\
/
'
;
function
Composite
(
targetGroup
,
path
,
optionalParsedPath
)
{
var
parsedPath
=
optionalParsedPath
||
PropertyBinding
.
parseTrackName
(
path
);
...
...
@@ -111,33 +114,41 @@ Object.assign( PropertyBinding, {
*/
sanitizeNodeName
:
function
(
name
)
{
return
name
.
replace
(
/
\s
/g
,
'
_
'
).
replace
(
/
[^\w
-
]
/g
,
''
);
var
reservedRe
=
new
RegExp
(
'
[
'
+
RESERVED_CHARS_RE
+
'
]
'
,
'
g
'
);
return
name
.
replace
(
/
\s
/g
,
'
_
'
).
replace
(
reservedRe
,
''
);
},
parseTrackName
:
function
()
{
// Attempts to allow node names from any language. ES5's `\w` regexp matches
// only latin characters, and the unicode \p{L} is not yet supported. So
// instead, we exclude reserved characters and match everything else.
var
wordChar
=
'
[^
'
+
RESERVED_CHARS_RE
+
'
]
'
;
var
wordCharOrDot
=
'
[^
'
+
RESERVED_CHARS_RE
.
replace
(
'
\\
.
'
,
''
)
+
'
]
'
;
// Parent directories, delimited by '/' or ':'. Currently unused, but must
// be matched to parse the rest of the track name.
var
directoryRe
=
/
((?:
[\w
-
]
+
[\/
:
])
*
)
/
;
var
directoryRe
=
/
((?:
WC+
[\/
:
])
*
)
/
.
source
.
replace
(
'
WC
'
,
wordChar
)
;
// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.
var
nodeRe
=
/
(
[\w
-
\.]
+
)?
/
;
var
nodeRe
=
/
(
WCOD+
)?
/
.
source
.
replace
(
'
WCOD
'
,
wordCharOrDot
)
;
// Object on target node, and accessor.
Name may contain only wor
d
// Object on target node, and accessor.
May not contain reserve
d
// characters. Accessor may contain any character except closing bracket.
var
objectRe
=
/
(?:\.(
[\w
-
]
+
)(?:\[(
.+
)\])?)?
/
;
var
objectRe
=
/
(?:\.(
WC+
)(?:\[(
.+
)\])?)?
/
.
source
.
replace
(
'
WC
'
,
wordChar
)
;
// Property and accessor. May
contain only wor
d characters. Accessor may
// Property and accessor. May
not contain reserve
d characters. Accessor may
// contain any non-bracket characters.
var
propertyRe
=
/
\.(
[\w
-
]
+
)(?:\[(
.+
)\])?
/
;
var
propertyRe
=
/
\.(
WC+
)(?:\[(
.+
)\])?
/
.
source
.
replace
(
'
WC
'
,
wordChar
)
;
var
trackRe
=
new
RegExp
(
''
+
'
^
'
+
directoryRe
.
source
+
nodeRe
.
source
+
objectRe
.
source
+
propertyRe
.
source
+
directoryRe
+
nodeRe
+
objectRe
+
propertyRe
+
'
$
'
);
...
...
test/unit/src/animation/PropertyBinding.tests.js
浏览文件 @
272411dd
...
...
@@ -41,6 +41,12 @@ export default QUnit.module( 'Animation', () => {
'
Leaves valid name intact.
'
);
assert
.
equal
(
PropertyBinding
.
sanitizeNodeName
(
'
急須
'
),
'
急須
'
,
'
Leaves non-latin unicode characters intact.
'
);
assert
.
equal
(
PropertyBinding
.
sanitizeNodeName
(
'
space separated name 123_ -
'
),
'
space_separated_name_123__-
'
,
...
...
@@ -48,9 +54,15 @@ export default QUnit.module( 'Animation', () => {
);
assert
.
equal
(
PropertyBinding
.
sanitizeNodeName
(
'
"invalid" name %123%_
'
),
'
invalid_name_123_
'
,
'
Strips invalid characters.
'
PropertyBinding
.
sanitizeNodeName
(
'
"Mátyás" %_* 😇
'
),
'
"Mátyás"_%_*_😇
'
,
'
Allows various punctuation and symbols.
'
);
assert
.
equal
(
PropertyBinding
.
sanitizeNodeName
(
'
/invalid: name ^123.[_]
'
),
'
invalid_name_^123_
'
,
'
Strips reserved characters.
'
);
}
);
...
...
@@ -236,7 +248,30 @@ export default QUnit.module( 'Animation', () => {
propertyName
:
'
position
'
,
propertyIndex
:
undefined
}
],
[
'
急須.材料[零]
'
,
{
nodeName
:
'
急須
'
,
objectName
:
undefined
,
objectIndex
:
undefined
,
propertyName
:
'
材料
'
,
propertyIndex
:
'
零
'
}
],
[
'
📦.🎨[🔴]
'
,
{
nodeName
:
'
📦
'
,
objectName
:
undefined
,
objectIndex
:
undefined
,
propertyName
:
'
🎨
'
,
propertyIndex
:
'
🔴
'
}
]
];
paths
.
forEach
(
function
(
path
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录